Realm.Sync.Adapter

Custom Data Connectors.

new Realm.Sync.Adapter(localPath, serverUrl, adminUser, regex, changeCallback, ssl)

Create a new Adapter to monitor and process changes made across multiple Realms

Parameters:
  • localPath
    • Type: string
    • the local path where realm files are stored

  • serverUrl
    • Type: string
    • the sync server to listen to

  • adminUser
    • Type: SyncUser
    • an admin user obtained by calling new Realm.Sync.User.adminUser

  • regex
    • Type: string
    • a regular expression used to determine which changed Realms should be monitored - use .* to match all all Realms

  • changeCallback
    • Type: function
    • called when a new transaction is available to process for the given realm_path

  • ssl optional
advance(path)

Advance the to the next transaction indicating that you are done processing the current instructions for the given Realm.

Parameters:
  • path
    • Type: string
    • the path for the Realm to advance

close()

Close the adapter and all opened Realms.

current(path)Array(instructions)

Get the Array of current instructions for the given Realm.

Properties:
  • INSERT
    • insert a new object

      • object_type - type of the object being inserted
      • identity - primary key value or row index for the object
      • values - map of property names and property values for the object to insert
  • SET
    • set property values for an existing object

      • object_type - type of the object
      • identity - primary key value or row index for the object
      • values - map of property names and property values to update for the object
  • DELETE
    • delete an exising object

      • object_type - type of the object
      • identity - primary key value or row index for the object
  • CLEAR
    • delete all objects of a given type

      • object_type - type of the object
  • LIST_SET
    • set the object at a given list index to an object

      • object_type - type of the object
      • identity - primary key for the object
      • property - property name for the list property to mutate
      • list_index - list index to set
      • object_identity - primary key or row number of the object being set
  • LIST_INSERT
    • insert an object in the list at the given index

      • object_type - type of the object
      • identity - primary key for the object
      • property - property name for the list property to mutate
      • list_index - list index at which to insert
      • object_identity - primary key or row number of the object to insert
  • LIST_ERASE
    • erase an object in the list at the given index - this removes the object from the list but the object will still exist in the Realm

      • object_type - type of the object
      • identity - primary key for the object
      • property - property name for the list property to mutate
      • list_index - list index which should be erased
  • LIST_CLEAR
    • clear a list removing all objects - objects are not deleted from the Realm

      • object_type - type of the object
      • identity - primary key for the object
      • property - property name for the list property to clear
  • ADD_TYPE
    • add a new type

      • object_type - name of the type
      • primary_key - name of primary key property for this type
      • properties - Property map as described in Realm~ObjectSchema
  • ADD_PROPERTIES
    • add properties to an existing type

      • object_type - name of the type
      • properties - Property map as described in Realm~ObjectSchema
  • CHANGE_IDENTITY
    • change the row index for an existing object - not called for objects with primary keys

      • object_type - type fo the object
      • identity - old row value for the object
      • new_identity - new row value for the object
Parameters:
  • path
    • Type: string
    • the path for the Realm being monitored

      The following Instructions can be returned. Each instruction object has a type property which is one of the following types. For each type below we list the other properties that will exist in the instruction object.

Returns: Array(instructions) or {undefined} if all transactions have been processed
realmAtPath(path, optional)Realm

Open the Realm used by the Adapter for the given path. This is useful for writing two way adapters as transactions written to this realm will be ignored when calling current and advance

Parameters:
  • path
    • Type: string
    • the path for the Realm to open

  • optional optional
    • Type: [ObjectSchema, ...]
    • schema - schema to apply when opening the Realm

Returns: Realm