Reference
Reference
A model representing a record reference in Skygear record.
Static Method Summary
Static Public Methods | ||
public static |
Deserializes Reference from a JSON object. |
Constructor Summary
Public Constructor | ||
public |
constructor(recordOrRecordType: Record | String, recordID: String) Constructs a new Reference object. |
Member Summary
Public Members | ||
public get |
id: String this get was deprecated. Use `recordType` and `recordID` instead.
ID of the referencing record in the deprecated format (i.e. |
|
public get |
recordID: String ID of the referencing record. |
|
public get |
recordType: String Type of the referencing record. |
Method Summary
Public Methods | ||
public |
toJSON(): Object Serializes Reference to a JSON object. |
Static Public Methods
Public Constructors
public constructor(recordOrRecordType: Record | String, recordID: String) source
Constructs a new Reference object.
Params:
Name | Type | Attribute | Description |
recordOrRecordType | Record | String | the referencing record or the record type |
|
recordID | String |
|
the referencing record ID |
Example:
let record = new Record('note', {
_recordType: 'note',
_recordID: '123',
content: 'hello world',
});
let ref = new Reference(record);
console.log('type', ref.recordType); // note
console.log('id', ref.recordType); // 123
let ref = new Reference('note', '123');
console.log('type', ref.recordType); // note
console.log('id', ref.recordType); // 123
// WARNING: This usage is deprecated
let ref = new Reference('note/123');
console.log('type', ref.recordType); // note
console.log('id', ref.recordType); // 123
Public Members
public get id: String source
ID of the referencing record in the deprecated format
(i.e. type/id
).
Public Methods
public toJSON(): Object source
Serializes Reference to a JSON object.
Return:
Object | the JSON object |