Google Apps Script

ScriptDB Service

This service provides access to a simple database unique to each script. See also the guide to ScriptDb.

Classes

NameBrief description
MutationResultA representation of the result for a single item in a batch mutation operation.
QueryOperatorA special object that can be used as a value in the query objects accepted by ScriptDbInstance.query(query) and ScriptDbInstance.count(query).
ScriptDbThe ScriptDB service, which provides access to ScriptDbInstances.
ScriptDbInstanceA JavaScript object database for permanently storing data.
ScriptDbMapAn item that was saved to or retrieved from the database.
ScriptDbResultAn object that provides iterator-like access to the results of a database query.
SortDirectionWhen ordering results, specifies which direction they should be ordered.
SortStrategyWhen 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

MethodReturn typeBrief description
successful()BooleanReturns true if the mutation was successful.

Class QueryOperator

Class ScriptDb

Methods

MethodReturn typeBrief description
getMyDb()ScriptDbInstanceReturns the database associated with the current script.

Class ScriptDbInstance

Properties

PropertyTypeDescription
ASCENDINGSortDirectionAscending sort direction.
DESCENDINGSortDirectionDescending sort direction.
LEXICALSortStrategyLexical sort strategy.
NUMERICSortStrategyNumeric sort strategy.

Methods

MethodReturn typeBrief description
allOk(mutateResults)BooleanReturns true if all of the items in the result set were successful.
anyOf(values)QueryOperatorReturns a query operator that evaluates to true if the field's value matches any of the passed in values.
anyValue()QueryOperatorReturns a query operator that evaluates to true if the field has any value.
between(value1, value2)QueryOperatorReturns a query operator that evaluates to true if the field has a value in-between the two passed in values.
count(query)IntegerReturns the number of items that match the query.
greaterThan(value)QueryOperatorReturns a query operator that evaluates to true if the field's value is greater than the passed in value.
greaterThanOrEqualTo(value)QueryOperatorReturns a query operator that evaluates to true if the field's value is greater than or equal to the passed in value.
lessThan(value)QueryOperatorReturns a query operator that evaluates to true if the field's value is less than the passed in value.
lessThanOrEqualTo(value)QueryOperatorReturns a query operator that evaluates to true if the field's value is less than or equal to the passed in value.
load(id)ScriptDbMapLoads an item from the database by id.
load(ids)ScriptDbMap[]Loads items from the database by id.
not(value)QueryOperatorReturns a query operator that evaluates to true if the field's value does not match the passed in value.
query(query)ScriptDbResultQuery the database for matching items.
remove(item)voidRemoves an item from the database.
removeBatch(items, atomic)MutationResult[]Removes items from the database.
removeById(id)voidRemoves an item from the database by id.
removeByIdBatch(ids, atomic)MutationResult[]Removes items from the database by id.
save(item)ScriptDbMapSaves a new item to the database.
save(item)ScriptDbMapSaves an existing item to the database, updating it.
saveBatch(items, atomic)Object[]Saves items to the database.

Class ScriptDbMap

Methods

MethodReturn typeBrief description
getId()StringReturns the item's id in the database.
toJson()StringReturns the JSON string representation of this object.

Class ScriptDbResult

Methods

MethodReturn typeBrief description
getSize()IntegerReturns the total number of items in the query results.
hasNext()BooleanReturns true if there are more items left in the query results.
limit(number)ScriptDbResultLimits the number of items in the query results.
next()ScriptDbMapReturns the next item in the query results.
paginate(pageNumber, pageSize)ScriptDbResultLimits the query results to a single page of items, using the passed in page number and size.
sortBy(fieldPath)ScriptDbResultSorts the query results by the specified field, lexically and ascending.
sortBy(fieldPath, direction)ScriptDbResultSorts the query results by the specified field, lexically and using the passed in direction.
sortBy(fieldPath, direction, strategy)ScriptDbResultSorts the query results by the specified field, using the passed in direction and strategy.
sortBy(fieldPath, strategy)ScriptDbResultSorts the query results by the specified field, ascending and using the passed in strategy.
startAt(number)ScriptDbResultStarts the query results with the item at the passed in index.

Class SortDirection

Properties

PropertyTypeDescription
DESCENDINGEnum
ASCENDINGEnum

Class SortStrategy

Properties

PropertyTypeDescription
LEXICALEnum
NUMERICEnum

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.