Record
Record provides the model for Skygear Database to interact with server.
Developer may use Record.extend to create custom record type.
Static Method Summary
Static Public Methods | ||
public static |
extend(recordType: String, instMethods: Map<String, Function>): Class Extends a Record class with a record type |
|
public static |
fromJSON(obj: Object): * Constructs a new Record object from JSON object. |
Constructor Summary
Public Constructor | ||
public |
|
Member Summary
Public Members | ||
public get |
$transient: Object Returns a dictionary of transient fields. |
|
public |
[key]: * |
|
public |
|
|
public get |
ACL of the record. |
|
public set |
|
|
public get |
attributeKeys: String[] Gets all keys of attributes of the records. |
|
public get |
id: String this get was deprecated. Use `recordType` and `recordID` instead.
ID of the record in the deprecated format (i.e. |
|
public get |
metaKeys: String[] Gets all keys of attributes of the records, includig reserved keys. |
|
public get |
recordID: String ID of the record. |
|
public get |
recordType: String Type of the record. |
Method Summary
Public Methods | ||
public |
hasPublicReadAccess(): Boolean Checks if public has read access. |
|
public |
hasPublicWriteAccess(): Boolean Checks if public has write access. |
|
public |
hasReadAccessForRole(role: Role): Boolean Checks if the specific role has read access. |
|
public |
hasReadAccessForUser(user: Record): Boolean Checks if the specific user has read access. |
|
public |
hasWriteAccessForRole(role: Role): Boolean Checks if the specific role has write access. |
|
public |
hasWriteAccessForUser(user: Record): Boolean Checks if the specific user has write access. |
|
public |
Set ACL of the record. |
|
public |
setNoAccessForRole(role: Role) Sets a specific role to have no access. |
|
public |
setNoAccessForUser(user: Record) Sets a specific user to have no access. |
|
public |
Sets public to have no access. |
|
public |
Sets public to have read access only. |
|
public |
Sets the record readable and writable to public. |
|
public |
setReadOnlyForRole(role: Role) Sets a specific role to have read access only. |
|
public |
setReadOnlyForUser(user: Record) Sets a specific user to have read access only. |
|
public |
setReadWriteAccessForRole(role: Role) Sets a specific role to have read and write access. |
|
public |
setReadWriteAccessForUser(user: Record) Sets a specific user to have read and write access. |
|
public |
toJSON(): Object Serializes Record to a JSON object. |
|
public |
toTruncatedJSON(): Object Serializes Record to a JSON object without metadata keys. |
|
public |
update(attrs: Object) Updates record attributes with a dictionary. |
Static Public Methods
public static extend(recordType: String, instMethods: Map<String, Function>): Class source
Extends a Record class with a record type
Params:
Name | Type | Attribute | Description |
recordType | String | record type |
|
instMethods | Map<String, Function> | instance methods |
Return:
Class |
Example:
const Note = skygear.Record.extend('note');
const note = new Note({ 'content': 'abc' });
public static fromJSON(obj: Object): * source
Constructs a new Record object from JSON object.
Params:
Name | Type | Attribute | Description |
obj | Object | the JSON object |
Return:
* |
Public Constructors
public constructor() source
Public Members
public get $transient: Object source
Returns a dictionary of transient fields.
Transient fields are attached to an instance of Record and it is never persisted on server, but they may be returned as extra data about the record when fetched or queried from server with Query#transientInclude.
public [key]: * source
public [meta.newKey]: * source
public get attributeKeys: String[] source
Gets all keys of attributes of the records. Skygear reserved keys, that is underscore prefixed keys, are excluded.
public get id: String source
ID of the record in the deprecated format (i.e. type/id
).
public get metaKeys: String[] source
Gets all keys of attributes of the records, includig reserved keys.
Public Methods
public hasPublicReadAccess(): Boolean source
Checks if public has read access.
Return:
Boolean | true if public has read access |
public hasPublicWriteAccess(): Boolean source
Checks if public has write access.
Return:
Boolean | true if public has write access |
public hasReadAccessForRole(role: Role): Boolean source
Checks if the specific role has read access.
Params:
Name | Type | Attribute | Description |
role | Role | the role |
Return:
Boolean | true if the role has read access |
public hasReadAccessForUser(user: Record): Boolean source
Checks if the specific user has read access.
Params:
Name | Type | Attribute | Description |
user | Record | the user |
Return:
Boolean | true if the user has read access |
public hasWriteAccessForRole(role: Role): Boolean source
Checks if the specific role has write access.
Params:
Name | Type | Attribute | Description |
role | Role | the role |
Return:
Boolean | true if the role has write access |
public hasWriteAccessForUser(user: Record): Boolean source
Checks if the specific user has write access.
Params:
Name | Type | Attribute | Description |
user | Record | the user |
Return:
Boolean | true if the user has write access |
public setAccess(acl: ACL) source
Set ACL of the record.
Params:
Name | Type | Attribute | Description |
acl | ACL |
public setNoAccessForRole(role: Role) source
Sets a specific role to have no access.
Params:
Name | Type | Attribute | Description |
role | Role | the role |
public setNoAccessForUser(user: Record) source
Sets a specific user to have no access.
Params:
Name | Type | Attribute | Description |
user | Record | the user record |
public setReadOnlyForRole(role: Role) source
Sets a specific role to have read access only.
Params:
Name | Type | Attribute | Description |
role | Role | the role |
public setReadOnlyForUser(user: Record) source
Sets a specific user to have read access only.
Params:
Name | Type | Attribute | Description |
user | Record | the user record |
public setReadWriteAccessForRole(role: Role) source
Sets a specific role to have read and write access.
Params:
Name | Type | Attribute | Description |
role | Role | the role |
public setReadWriteAccessForUser(user: Record) source
Sets a specific user to have read and write access.
Params:
Name | Type | Attribute | Description |
user | Record | the user record |
public toTruncatedJSON(): Object source
Serializes Record to a JSON object without metadata keys.
Return:
Object | the JSON object |
public update(attrs: Object) source
Updates record attributes with a dictionary.
Params:
Name | Type | Attribute | Description |
attrs | Object |