This service provides access to a simple database unique to each script. See also the guide to ScriptDb.
Classes
Name | Brief description |
---|---|
MutationResult | A representation of the result for a single item in a batch mutation operation. |
QueryOperator | A special object that can be used as a value in the query objects accepted by
ScriptDbInstance.query(query) and ScriptDbInstance.count(query) . |
ScriptDb | The ScriptDb service, which provides access to ScriptDbInstance s. |
ScriptDbInstance | A JavaScript object database for permanently storing data. |
ScriptDbMap | An item that was saved to or retrieved from the database. |
ScriptDbResult | An object that provides iterator-like access to the results of a database query. |
SortDirection | When ordering results, specifies which direction they should be ordered. |
SortStrategy | When ordering results, should we sort lexically, or when sorting numbers, sort them as if they were numbers (since lexical sorting doesn't do what you want). |
Class MutationResult
Methods
Method | Return type | Brief description |
---|---|---|
MutationResult.successful() | Boolean | Returns true if the mutation was successful. |
Class QueryOperator
Class ScriptDb
Methods
Method | Return type | Brief description |
---|---|---|
ScriptDb.getMyDb() | ScriptDbInstance | Returns the database associated with the current script. |
Class ScriptDbInstance
Properties
Property | Type | Description |
---|---|---|
ASCENDING | SortDirection | Ascending sort direction. |
DESCENDING | SortDirection | Descending sort direction. |
LEXICAL | SortStrategy | Lexical sort strategy. |
NUMERIC | SortStrategy | Numeric sort strategy. |
Methods
Method | Return type | Brief description |
---|---|---|
ScriptDbInstance.allOk(mutateResults) | Boolean | Returns true if all of the items in the result set were successful. |
ScriptDbInstance.anyOf(values) | QueryOperator | Returns a query operator that evaluates to true if the field's value matches any of the passed in values. |
ScriptDbInstance.anyValue() | QueryOperator | Returns a query operator that evaluates to true if the field has any value. |
ScriptDbInstance.between(value1, value2) | QueryOperator | Returns a query operator that evaluates to true if the field has a value in-between the two passed in values. |
ScriptDbInstance.count(query) | Integer | Returns the number of items that match the query. |
ScriptDbInstance.greaterThan(value) | QueryOperator | Returns a query operator that evaluates to true if the field's value is greater than the passed in value. |
ScriptDbInstance.greaterThanOrEqualTo(value) | QueryOperator | Returns a query operator that evaluates to true if the field's value is greater than or equal to the passed in value. |
ScriptDbInstance.lessThan(value) | QueryOperator | Returns a query operator that evaluates to true if the field's value is less than the passed in value. |
ScriptDbInstance.lessThanOrEqualTo(value) | QueryOperator | Returns a query operator that evaluates to true if the field's value is less than or equal to the passed in value. |
ScriptDbInstance.load(id) | ScriptDbMap | Loads an item from the database by id. |
ScriptDbInstance.load(ids) | ScriptDbMap[] | Loads items from the database by id. |
ScriptDbInstance.not(value) | QueryOperator | Returns a query operator that evaluates to true if the field's value does not match the passed in value. |
ScriptDbInstance.query(query) | ScriptDbResult | Query the database for matching items. |
ScriptDbInstance.remove(item) | void | Removes an item from the database. |
ScriptDbInstance.removeBatch(items, atomic) | MutationResult[] | Removes items from the database. |
ScriptDbInstance.removeById(id) | void | Removes an item from the database by id. |
ScriptDbInstance.removeByIdBatch(ids, atomic) | MutationResult[] | Removes items from the database by id. |
ScriptDbInstance.save(item) | ScriptDbMap | Saves a new item to the database. |
ScriptDbInstance.save(item) | ScriptDbMap | Saves an existing item to the database, updating it. |
ScriptDbInstance.saveBatch(items, atomic) | Object[] | Saves items to the database. |
Class ScriptDbMap
Methods
Method | Return type | Brief description |
---|---|---|
ScriptDbMap.getId() | String | Returns the item's id in the database. |
ScriptDbMap.toJson() | String | Returns the JSON string representation of this object. |
Class ScriptDbResult
Methods
Method | Return type | Brief description |
---|---|---|
ScriptDbResult.getSize() | Integer | Returns the total number of items in the query results. |
ScriptDbResult.hasNext() | Boolean | Returns true if there are more items left in the query results. |
ScriptDbResult.limit(number) | ScriptDbResult | Limits the number of items in the query results. |
ScriptDbResult.next() | ScriptDbMap | Returns the next item in the query results. |
ScriptDbResult.paginate(pageNumber, pageSize) | ScriptDbResult | Limits the query results to a single page of items, using the passed in page number and size. |
ScriptDbResult.sortBy(fieldPath) | ScriptDbResult | Sorts the query results by the specified field, lexically and ascending. |
ScriptDbResult.sortBy(fieldPath, direction) | ScriptDbResult | Sorts the query results by the specified field, lexically and using the passed in direction. |
ScriptDbResult.sortBy(fieldPath, direction, strategy) | ScriptDbResult | Sorts the query results by the specified field, using the passed in direction and strategy. |
ScriptDbResult.sortBy(fieldPath, strategy) | ScriptDbResult | Sorts the query results by the specified field, ascending and using the passed in strategy. |
ScriptDbResult.startAt(number) | ScriptDbResult | Starts the query results with the item at the passed in index. |
Class SortDirection
Properties
Property | Type | Description |
---|---|---|
DESCENDING | Enum | |
ASCENDING | Enum |
Class SortStrategy
Properties
Property | Type | Description |
---|---|---|
LEXICAL | Enum | |
NUMERIC | Enum |