Skygear supports a lot of different data types, such as:
There are also four other types provided by Skygear SDK:
Skygear supports many-to-one (aka. parent-child) relation between records via reference.
SKYReference is a pointer to a record in database. Let's say we are going to
reference Record A in Record B, we first construct a reference of Record A
using its id.
// aID is a placeholder of Record A's id SKYReference *aRef = [SKYReference referenceWithRecordID:aID];
``swift // aID is a placeholder of Record A's id let aRef = SKYReference(recordID: aID)
Then assign this reference as a regular field of Record B: ```obj-c // bRecord is a placeholder of Record B's object bRecord[@"parent"] = aRef;
// bRecord is a placeholder of Record B's object bRecord?.setObject(aRef, forKey: "parent" as NSCopying!)
It will establish a reference from Record B to Record A.
Skygear reserves the
id field in the top level of all record as a primary key.
id must be unique and default to be Version 4 UUID. If you want to
auto-incrementing id for display purpose, Skygear provide a sequence for this
purpose. The sequence is guaranteed unique.
noteIDon update, the value will remain unchanged.
Notein the database will now automatically have their
Notewill be a sequence type once migrated.
See Location and Maps Programming Guide for help on getting current location.
Get all photos taken within 400 meters of some location.
distanceToLocation:fromLocation: is a Skygear function which returns distance
between a location field in a record and a specific location.
Cont. from the example above.
Utilize transient fields.
Then we can access the distance in
completionHandler like this:
You can make use of
Asset to store file references such as images and videos on the database. An asset can only be saved with a record but not as a standalone upload.
Skygear automatically uploads the files to a server that you specify, like Amazon S3.
For example, you want to allow users to upload an image as an
image to his
SKYRecord. Once the user has selected the image to upload, you can save it by:
Asset names will never collide. i.e. you can upload multiple assets with the same asset name.
asset.name is rewritten after the asset being uploaded.
SKYAsset.url will be populated with an expiry URL after fetching /
querying the record from server.