Skip to content

Commit

Permalink
Select2Object() class
Browse files Browse the repository at this point in the history
A class used by script only (GAS).  Rather than referenced sheet data by a column position, the data is returned as a single array of objects.  Each object has a property value name that is created by the returned column name.
  • Loading branch information
demmings committed Dec 29, 2023
1 parent dcb562c commit ec567d4
Show file tree
Hide file tree
Showing 7 changed files with 4,150 additions and 3,491 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,32 @@ let data = new Sql()
4. Documentation for using:
* https://demmings.github.io/docs/gssql/index.html

5. Select2Object Class
* The Sql() class returns selected data as a double array. The Select2Object() class returns the same data, but in the form of an array of objects.
* Each column is referenced as a property value rather than data in a column. Using Sql() object, the column number of expected data would be the offset of select column in the SQL statement. If the column position changed, your javascript code would require updating.
* Using Select2Object().
* Executes a SELECT statement on sheet data.
* Returned data will be any array of objects, where each item is one row of data.
* The property values in the object are the column names.
* The column names will be in lower case.
* If more than one table is referenced, the column name will be: "table.column", otherwise it will just be the column name.
* Spaces in the column name use the underscore, so something like "Transaction Date" would be referenced as "transaction_date".
* When defining each table (addTableData()), you set the name and the data source. This source can be
* a double array of data (with column titles)
* a sheet name
* a named range
* an A1 notation range.

* Example:

```
let stmt = "select * from authors";
let data = new Select2Object()
.addTableData("authors", this.authorsTable())
.execute(stmt);
```

---

# Installing
Expand Down
Loading

0 comments on commit ec567d4

Please sign in to comment.