Database
Constructor Summary
| Public Constructor | ||
| public |
constructor(dbID: String, container: Container): Database Creates a Skygear database. |
|
Member Summary
| Public Members | ||
| public get |
cacheResponse: boolean Indicating if query result should be cached locally |
|
| public set |
cacheResponse: boolean Indicating if query result should be cached locally |
|
| public get |
cacheStore: Store |
|
| public |
dbID: String The database ID |
|
Method Summary
| Public Methods | ||
| public |
async del(record: Record | Record[] | QueryResult): Promise<Record> Same as Database#delete. |
|
| public |
async delete(_records: Record | Record[] | QueryResult): Promise Deletes a record or records to Skygear. |
|
| public |
async getRecordByID(id: String): Promise<Record> Fetches a single record with the specified id from Skygear. |
|
| public |
async query(query: Query, cacheCallback: function(queryResult: QueryResult, isCached: boolean)): Promise<QueryResult> Fetches records that match the Query from Skygear. |
|
| public |
Saves a record or records to Skygear. |
|
| public |
uploadAsset(asset: Asset): Promise<Asset> Uploads asset to Skygear server. |
|
Public Constructors
Public Members
public get cacheStore: Store source
Public Methods
public async del(record: Record | Record[] | QueryResult): Promise<Record> source
Same as Database#delete.
Params:
| Name | Type | Attribute | Description |
| record | Record | Record[] | QueryResult | the record(s) to delete |
See:
public async delete(_records: Record | Record[] | QueryResult): Promise source
Deletes a record or records to Skygear.
Use this method to delete a record or records to Skygear. The delete will be performed asynchronously and the returned promise will be resolved when the operation completes.
Params:
| Name | Type | Attribute | Description |
| _records | Record | Record[] | QueryResult | the records to delete |
Return:
| Promise | promise |
public async getRecordByID(id: String): Promise<Record> source
Fetches a single record with the specified id from Skygear.
Use this method to fetch a single record from Skygear by specifying a
record ID in the format of type/id. The fetch will be performed
asynchronously and the returned promise will be resolved when the
operation completes.
Params:
| Name | Type | Attribute | Description |
| id | String | record ID with format |
public async query(query: Query, cacheCallback: function(queryResult: QueryResult, isCached: boolean)): Promise<QueryResult> source
Fetches records that match the Query from Skygear.
Use this method to fetch records from Skygear by specifying a Query. The fetch will be performed asynchronously and the returned promise will be resolved when the operation completes.
If cacheCallback is provided, the SDK would try to fetch result of the query from local cache, before issuing query request to the server, and trigger the cacheCallback function if cached result is found.
Params:
| Name | Type | Attribute | Description |
| query | Query | ||
| cacheCallback | function(queryResult: QueryResult, isCached: boolean) |
public async save(_records: Record | Record[], options: Object): Promise<Record> source
Saves a record or records to Skygear.
Use this method to save a record or records to Skygear. The save will be performed asynchronously and the returned promise will be resolved when the operation completes.
New record will be created in the database while existing record will be modified.
options.atomic can be set to true, which makes the operation either success or failure, but not partially success.
