Class: UserBridgeStore

UserBridgeStore(db, opts)

new UserBridgeStore(db, opts)

Construct a store suitable for user bridging information.
Parameters:
Name Type Description
db Datastore The connected NEDB database instance
opts Object Options for this store.
Source:

Methods

getByMatrixData(dataQuery) → {Promise.<Array.<MatrixUser>, Error>}

Get Matrix users by some data about them, previously stored via the set method on the Matrix user.
Parameters:
Name Type Description
dataQuery Object The keys and matching values the remote users share. This should use dot notation for nested types. For example: { "topLevel.midLevel.leaf": 42, "otherTopLevel": "foo" }
Source:
Throws:
If dataQuery isn't an object.
Returns:
Resolves to a possibly empty list of MatrixUsers. Rejects with an error if there was a problem querying the store.
Type
Promise.<Array.<MatrixUser>, Error>
Example
matrixUser.set({
  toplevel: "foo",
  nested: {
    bar: {
      baz: 43
    }
  }
});
store.setMatrixUser(matrixUser).then(function() {
  store.getByMatrixData({
    "toplevel": "foo",
    "nested.bar.baz": 43
  })
});

getByMatrixLocalpart(localpart) → {Promise.<?MatrixUser, Error>}

Retrieve a MatrixUser based on their user ID localpart. If there is more than one match (e.g. same localpart, different domains) then this will return an arbitrary matching user.
Parameters:
Name Type Description
localpart string The user localpart
Source:
Returns:
Resolves to a MatrixUser or null.
Type
Promise.<?MatrixUser, Error>

getByRemoteData(dataQuery) → {Promise.<Array.<RemoteUser>, Error>}

Get remote users by some data about them, previously stored via the set method on the Remote user.
Parameters:
Name Type Description
dataQuery Object The keys and matching values the remote users share. This should use dot notation for nested types. For example: { "topLevel.midLevel.leaf": 42, "otherTopLevel": "foo" }
Source:
Throws:
If dataQuery isn't an object.
Returns:
Resolves to a possibly empty list of RemoteUsers. Rejects with an error if there was a problem querying the store.
Type
Promise.<Array.<RemoteUser>, Error>
Example
remoteUser.set({
  toplevel: "foo",
  nested: {
    bar: {
      baz: 43
    }
  }
});
store.setRemoteUser(remoteUser).then(function() {
  store.getByRemoteData({
    "toplevel": "foo",
    "nested.bar.baz": 43
  })
});
Retrieve a list of matrix user IDs linked to this remote ID.
Parameters:
Name Type Description
remoteId string The remote ID
Source:
Returns:
A list of user IDs.
Type
Promise.<Array.<String>, Error>

getMatrixUser(userId) → {Promise.<?MatrixUser, Error>}

Get a matrix user by their user ID.
Parameters:
Name Type Description
userId string The user_id
Source:
Returns:
Resolves to the user or null if they do not exist. Rejects with an error if there was a problem querying the store.
Type
Promise.<?MatrixUser, Error>

getMatrixUsersFromRemoteId(remoteId) → {Promise.<Array.<MatrixUser>, Error>}

Retrieve a list of corresponding matrix users for the given remote ID.
Parameters:
Name Type Description
remoteId string The Remote ID
Source:
Returns:
Resolves to a list of Matrix users.
Type
Promise.<Array.<MatrixUser>, Error>
Retrieve a list of remote IDs linked to this matrix user ID.
Parameters:
Name Type Description
matrixId string The matrix user ID
Source:
Returns:
A list of remote IDs.
Type
Promise.<Array.<String>, Error>

getRemoteUser(id) → {Promise.<?RemoteUser, Error>}

Get a remote user by their remote ID.
Parameters:
Name Type Description
id string The remote ID
Source:
Returns:
Resolves to the user or null if they do not exist. Rejects with an error if there was a problem querying the store.
Type
Promise.<?RemoteUser, Error>

getRemoteUsersFromMatrixId(userId) → {Promise.<Array.<RemoteUser>, Error>}

Retrieve a list of corresponding remote users for the given matrix user ID.
Parameters:
Name Type Description
userId string The Matrix user ID
Source:
Returns:
Resolves to a list of Remote users.
Type
Promise.<Array.<RemoteUser>, Error>

linkUsers(matrixUser, remoteUser) → {Promise}

Create a link between a matrix and remote user. If either user does not exist, they will be inserted prior to linking. This is done to ensure foreign key constraints are satisfied (so you cannot have a mapping to a user ID which does not exist).
Parameters:
Name Type Description
matrixUser MatrixUser The matrix user
remoteUser RemoteUser The remote user
Source:
Returns:
Type
Promise

setMatrixUser(matrixUser) → {Promise}

Store a Matrix user. If they already exist, they will be updated. Equivalence is determined by their user ID.
Parameters:
Name Type Description
matrixUser MatrixUser The matrix user
Source:
Returns:
Type
Promise

setRemoteUser(remoteUser) → {Promise}

Store a Remote user. If they already exist, they will be updated. Equivalence is determined by the Remote ID.
Parameters:
Name Type Description
remoteUser RemoteUser The remote user
Source:
Returns:
Type
Promise

unlinkUserIds(matrixUserId, remoteUserId) → {Promise.<Number, Error>}

Delete a link between a matrix user ID and a remote user ID.
Parameters:
Name Type Description
matrixUserId string The matrix user ID
remoteUserId string The remote user ID
Source:
Returns:
Resolves to the number of entries removed.
Type
Promise.<Number, Error>

unlinkUsers(matrixUser, remoteUser) → {Promise.<Number, Error>}

Delete a link between a matrix user and a remote user.
Parameters:
Name Type Description
matrixUser MatrixUser The matrix user
remoteUser RemoteUser The remote user
Source:
Returns:
Resolves to the number of entries removed.
Type
Promise.<Number, Error>