Home Reference Source
public class | source

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

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

setAccess(acl: ACL)

Set ACL of the record.

public

Sets a specific role to have no access.

public

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

Sets a specific role to have read access only.

public

Sets a specific user to have read access only.

public

Sets a specific role to have read and write access.

public

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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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 access: ACL source

ACL of the record.

public set access: ACL 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

this get was deprecated. Use `recordType` and `recordID` instead.

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 get recordID: String source

ID of the record.

public get recordType: String source

Type of the record.

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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
user Record

the user

Return:

Boolean

true if the user has write access

public setAccess(acl: ACL) source

Set ACL of the record.

Params:

NameTypeAttributeDescription
acl ACL

public setNoAccessForRole(role: Role) source

Sets a specific role to have no access.

Params:

NameTypeAttributeDescription
role Role

the role

public setNoAccessForUser(user: Record) source

Sets a specific user to have no access.

Params:

NameTypeAttributeDescription
user Record

the user record

public setPublicNoAccess() source

Sets public to have no access.

public setPublicReadOnly() source

Sets public to have read access only.

public setPublicReadWriteAccess() source

Sets the record readable and writable to public.

public setReadOnlyForRole(role: Role) source

Sets a specific role to have read access only.

Params:

NameTypeAttributeDescription
role Role

the role

public setReadOnlyForUser(user: Record) source

Sets a specific user to have read access only.

Params:

NameTypeAttributeDescription
user Record

the user record

public setReadWriteAccessForRole(role: Role) source

Sets a specific role to have read and write access.

Params:

NameTypeAttributeDescription
role Role

the role

public setReadWriteAccessForUser(user: Record) source

Sets a specific user to have read and write access.

Params:

NameTypeAttributeDescription
user Record

the user record

public toJSON(): Object source

Serializes Record to a JSON object.

Return:

Object

the JSON object

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:

NameTypeAttributeDescription
attrs Object