In Skygear, you can specify a type and an id for a
Record. A record type must be given when a record is instantiated, while its id will be generated afterwards if not given. We will talk more
Record id with examples in a later section.
You can assign attributes to a
Record. A key of an attribute must be a
String while its value can be of various types. All primitive types, array of primitive types and Java
Date type are currently supported.
Below are some examples on how attributes can be set and retrieved.
Creating a record
To save just a single record or multiple records, a
RecordSaveResponseHandler has to be instantiated first.
If a record has been given an ID that already exists on the cloud
database, saving this record will update the existing record.
A record can be saved to either the public or private database. Here is an example saving the record
note1 we have created above to a public database.
Creating multiple records
To save multiple records at one time, put them in an array:
You can also save multiple records atomically, where result of the save operation can either be Success or Fail. Note that the callback
onPartiallySaveSuccess will not be triggered in such case.
Record(s) can be queried with conditions. You will have to
specify the conditions in a
The following code snippet shows how to perform record query with
For more information, please check out the More About Queries Section.
Deleting a record
You can delete a record on either the public or private database.
Here, we are going to use the record
note1 that was created and saved
above to demonstrate the process of deleting a record.
Deleting multiple records
Similar to the above handlers, you can delete multiple records at a time.