new RoomBridgeStore(db, opts)
Construct a store suitable for room bridging information.
Parameters:
Name | Type | Description |
---|---|---|
db |
Datastore | The connected NEDB database instance |
opts |
Object | Options for this store. |
- Source:
Methods
getLinkedMatrixRooms(remoteId, dataQueryopt) → {Promise.<Array.<MatrixRoom>, Error>}
Get Matrix rooms linked to the given remote ID.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
remoteId |
string | The remote room ID | |
dataQuery |
Object |
<optional> |
Additional constraints to apply to the set of returned rooms. |
- Source:
Returns:
A list of matrix rooms.
- Type
- Promise.<Array.<MatrixRoom>, Error>
getLinkedRemoteRooms(matrixId, dataQueryopt) → {Promise.<Array.<RemoteRoom>, Error>}
Get remote rooms linked to the given matrix ID.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
matrixId |
string | The matrix room ID | |
dataQuery |
Object |
<optional> |
Additional constraints to apply to the set of returned rooms. |
- Source:
Returns:
A list of remote rooms.
- Type
- Promise.<Array.<RemoteRoom>, Error>
getLinksByData(dataQuery)
Retrieve a list of links based on some information about the links themselves.
Parameters:
Name | Type | Description |
---|---|---|
dataQuery |
Object | The keys and matching values the links 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:
{Promise<{RoomBridgeStore~Link[], Error>} Resolves to a possibly
empty list of RoomBridgeStore~Link objects. Rejects with an error if
there was a problem querying the store.
Example
store.linkRoomIds("!foo:bar", "_foo_bar", {
custom: {
stuff: "goes here"
},
or: "here"
});
store.getLinksByData({
"custom.stuff": "goes here"
});
getMatrixLinks(remoteId) → {Promise.<Array.<RoomBridgeStore~Link>, Error>}
Retrieve a list of matrix room IDs linked to this remote ID.
Parameters:
Name | Type | Description |
---|---|---|
remoteId |
string | The remote ID |
- Source:
Returns:
A list of room IDs.
- Type
- Promise.<Array.<RoomBridgeStore~Link>, Error>
getMatrixRoom(roomIdOrDataQuery) → {Promise.<?MatrixRoom, Error>}
Get a matrix room by its' room ID.
Parameters:
Name | Type | Description |
---|---|---|
roomIdOrDataQuery |
string | Object | The room id or a data query object.
If the data query returns multiple entries, only 1 will be returned. Data queries
for keys set via MatrixRoom.set(key, val) MUST be prefixed with
'extras.' |
- Source:
- See:
-
- RoomBridgeStore.getMatrixRooms
Returns:
Resolves to the room or null if it
does not exist. Rejects with an error if there was a problem querying the store.
- Type
- Promise.<?MatrixRoom, Error>
getMatrixRooms(dataQuery) → {Promise.<Array.<MatrixRoom>, Error>}
Get a list of matrix rooms by a data query.
Parameters:
Name | Type | Description |
---|---|---|
dataQuery |
Object | A data query object. Queries for keys set via
MatrixRoom.set(key, val) MUST be prefixed with 'extras.' |
- Source:
Returns:
- Type
- Promise.<Array.<MatrixRoom>, Error>
Example
store.getMatrixRooms({
name: "A room name",
"extras.some_new_key": "some new val"
});
getRemoteLinks(matrixId) → {Promise.<Array.<RoomBridgeStore~Link>, Error>}
Retrieve a list of remote IDs linked to this matrix room ID.
Parameters:
Name | Type | Description |
---|---|---|
matrixId |
string | The matrix room ID |
- Source:
Returns:
A list of remote IDs.
- Type
- Promise.<Array.<RoomBridgeStore~Link>, Error>
getRemoteRoom(roomIdOrDataQuery) → {Promise.<?RemoteRoom, Error>}
Get a remote room by its' room ID.
Parameters:
Name | Type | Description |
---|---|---|
roomIdOrDataQuery |
string | Object | The room id or a data query object. If the data query returns multiple entries, only 1 will be returned. |
- Source:
Returns:
Resolves to the room or null if it
does not exist. Rejects with an error if there was a problem querying the store.
- Type
- Promise.<?RemoteRoom, Error>
getRemoteRooms(dataQuery) → {Promise.<Array.<RemoteRoom>, Error>}
Get a list of remote rooms by a data query.
Parameters:
Name | Type | Description |
---|---|---|
dataQuery |
Object | A data query object. |
- Source:
Returns:
- Type
- Promise.<Array.<RemoteRoom>, Error>
linkRooms(matrixRoom, remoteRoom, dataopt, linkKeyopt) → {Promise}
Create a link between a matrix room and remote room. This will insert the
given rooms if they do not exist before creating the mapping. This is done to
ensure foreign key constraints are satisfied (so you cannot have a mapping to
a room ID which does not exist).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
matrixRoom |
MatrixRoom | The matrix room | |
remoteRoom |
RemoteRoom | The remote room | |
data |
Object |
<optional> |
Information about this mapping. |
linkKey |
string |
<optional> |
An additional unique key value. |
- Source:
Returns:
- Type
- Promise
setMatrixRoom(matrixRoom, updateQuery) → {Promise}
Store a Matrix room. If it already exists, it will be updated. Equivalence
is determined by the room ID.
Parameters:
Name | Type | Description |
---|---|---|
matrixRoom |
MatrixRoom | The matrix room |
updateQuery |
Object | Update the room based on the data values given in this object rather than the matrix room ID. |
- Source:
Returns:
- Type
- Promise
setRemoteRoom(remoteRoom, updateQuery) → {Promise}
Store a Remote room. If it already exists, it will be updated. Equivalence
is determined by the room ID.
Parameters:
Name | Type | Description |
---|---|---|
remoteRoom |
RemoteRoom | The remote room |
updateQuery |
Object | Update the room based on the data values given in this object rather than the remote ID. |
- Source:
Returns:
- Type
- Promise
unlinkByData(dataQuery) → {Promise.<Number, Error>}
Delete links which have the matching data.
Parameters:
Name | Type | Description |
---|---|---|
dataQuery |
Object | The data query to match. |
- Source:
Returns:
Resolves to the number of entries removed.
- Type
- Promise.<Number, Error>
unlinkByKey(linkKey) → {Promise.<Number, Error>}
Delete a link between a matrix room ID and a remote room ID based on a link
key.
Parameters:
Name | Type | Description |
---|---|---|
linkKey |
string | The link key to delete links by. |
- Source:
Returns:
Resolves to the number of entries removed.
- Type
- Promise.<Number, Error>
unlinkRoomIds(matrixRoomId, remoteRoomId) → {Promise.<Number, Error>}
Delete a link between a matrix room ID and a remote room ID. This creates a
link key based on the provided IDs.
Parameters:
Name | Type | Description |
---|---|---|
matrixRoomId |
string | The matrix room ID |
remoteRoomId |
string | The remote room ID |
- Source:
Returns:
Resolves to the number of entries removed.
- Type
- Promise.<Number, Error>
unlinkRooms(matrixRoom, remoteRoom) → {Promise.<Number, Error>}
Delete a link between a matrix room and a remote room.
Parameters:
Name | Type | Description |
---|---|---|
matrixRoom |
MatrixUser | The matrix user |
remoteRoom |
RemoteUser | The remote user |
- Source:
Returns:
Resolves to the number of entries removed.
- Type
- Promise.<Number, Error>
Type Definitions
Link
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
matrix |
string | The matrix room ID |
remote |
string | The remote room ID |
link_key |
string | The unique key for this link. |
data |
Object | Information about this mapping, which may be an empty object. |
- Source: