A table is created from a database instance using Database::createTable method.
All data manipulation operations are transactional i.e until saved, none of the mutative queries are executed
Queues a query to insert the given rows.
table.insert(row[, row, ...rows]);| Param | Required | Type | Default | Description |
|---|---|---|---|---|
| ...rows | Yes | Object list | None | One or more objects to be inserted into the table |
- When one or more
rowsis not provided. - When one of the
rowsis not an object.
The current instance of Table.
- Does not mutate the table until
Table::saveis called. - Can be reverted before saving using
Table::revert.
Queries rows matched by the filter.
table.query([filter]);| Param | Required | Type | Default | Description |
|---|---|---|---|---|
| filter | No | one of
|
[Function: () => true] |
Takes in an id or an array of ids or a filter function that will be matched against row |
A Promise that resolves to a an array of rows that is matched by the given filter.
Queues a query to update the rows that are matched by the given filter, and run given update on each of the filtered row to get the updated row.
table.update(update[, filter]);| Param | Required | Type | Default | Description |
|---|---|---|---|---|
| update | Yes | Function | None | A non mutative function that will be run on each row |
| filter | No | one of
|
[Function: () => true] |
Takes in an id or an array of ids or a filter function that will be matched against row |
- When
udpateis not a function. - When
udpatemight mutate the row. - When
udpatemight return a value other than anObject.
The current instance of Table.
- Does not mutate the table until
Table::saveis called. - Can be reverted before saving using
Table::revert.
Queues a query to delete the rows that are matched by the given filter.
table.delete([filter]);| Param | Required | Type | Default | Description |
|---|---|---|---|---|
| filter | No | one of
|
[Function: () => true] |
Takes in an id or an array of ids or a filter function that will be matched against row |
The current instance of Table.
- Does not mutate the table until
Table::saveis called. - Can be reverted before saving using
Table::revert.
Saves queued queries to the table. Once done, it empties the query queue.
table.save();A Promise that would resolve once the queries are successfully saved to table.
Empties the pending query queue.
table.revert();The current instance of Table.