Realm objects will automatically inherit from this class unless a Realm~ObjectClass was specified that does not inherit from this class.

Since: 0.12.0

Add a listener callback which will be called when a live object instance changes.

  • callback
    • Type: function
    • A function to be called when changes occur. The callback function is called with two arguments:

      • obj: the object that changed,
      • changes: a dictionary with keys deleted, and changedProperties. deleted is true if the object has been deleted. changesProperties is an array of properties that have changed their value.
  • Error
    • If callback is not a function.

wine.addListener((obj, changes) => {
 // obj === wine
 console.log(`object is deleted: ${changes.deleted}`);
 console.log(`${changes.changedProperties.length} properties have been changed:`);
 changes.changedProperties.forEach(prop => {
     console.log(` ${prop}`);

Checks if this object has not been deleted and is part of a valid Realm.

Returns: boolean indicating if the object can be safely accessed.
linkingObjects(objectType, property)Realm.Results

Returns all the objects that link to this object in the specified relationship.

  • objectType
    • Type: string
    • The type of the objects that link to this object's type.

  • property
    • Type: string
    • The name of the property that references objects of this object's type.

  • Error
    • If the relationship is not valid.

Returns: Realm.Results the objects that link to this object.

Returns the total count of incoming links to this object

Returns: number number of links to this object.

Returns a unique identifier. For synced objects, the uniqueness is only guaranteed when the object has been synchronized.

See: objectForObjectId

Returns the schema for the type this object belongs to.

Returns: ObjectSchema the schema that describes this object.

Remove all listeners.


Remove the listener callback

  • callback
    • Type: function
    • A function previously added as listener