Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

  • Construct a store suitable for room bridging information. Data is stored as RoomBridgeStoreEntrys which have the following serialized format:

    {
    id: "unique_id", // customisable
    matrix_id: "room_id",
    remote_id: "remote_room_id",
    matrix: { serialised matrix room info },
    remote: { serialised remote room info },
    data: { ... any additional info ... }
    }

    If a unique 'id' is not given, the store will generate one by concatenating the matrix_id and the remote_id. The delimiter used is a property on this store and can be modified.

    The structure of Entry objects means that it is efficient to select based off the 'id', 'matrix_id' or 'remote_id'. Additional indexes can be added manually.

    Parameters

    • db: Nedb<any>

      The connected NEDB database instance

    Returns RoomBridgeStore

Properties

Readonly db

db: Nedb<any>

delimiter

delimiter: string = " "

Methods

batchGetLinkedRemoteRooms

  • batchGetLinkedRemoteRooms(matrixIds: string[]): Promise<{}>
  • A batched version of getLinkedRemoteRooms.

    see

    RoomBridgeStore#getLinkedRemoteRooms

    Parameters

    • matrixIds: string[]

    Returns Promise<{}>

    A mapping of room_id to RemoteRoom.

convertTo

  • convertTo<T, O>(func: (input: T) => O): (doc: T) => O
  • Convenience method to convert a document to something.

    Type parameters

    • T

    • O

    Parameters

    • func: (input: T) => O

      The function which will be called with a single document object. Guaranteed not to be null.

        • (input: T): O
        • Parameters

          • input: T

          Returns O

    Returns (doc: T) => O

    A transformFn function to pass to the standard select/delete/upsert/etc methods.

      • (doc: T): O
      • Parameters

        • doc: T

        Returns O

delete

  • delete(query: Query): Promise<number>

getEntriesByLinkData

  • Get a list of entries based on the link's data value.

    example

    store.linkRooms(matrixRoom, remoteRoom, { some_key: "some_val" }); store.getEntriesByLinkData({ some_key: "some_val" });

    Parameters

    • data: Record<string, unknown>

      The data values to retrieve based from.

    Returns Promise<RoomBridgeStoreEntry[]>

getEntriesByMatrixId

getEntriesByMatrixIds

  • getEntriesByMatrixIds(ids: string[]): Promise<{}>

getEntriesByMatrixRoomData

  • Get a list of entries based on a MatrixRoom data value.

    example

    matrixRoom.set("some_key", "some_val"); // store matrixRoom and then: store.getEntriesByMatrixRoomData({ some_key: "some_val" });

    Parameters

    • data: Record<string, unknown>

      The data values to retrieve based from.

    Returns Promise<RoomBridgeStoreEntry[]>

getEntriesByRemoteId

getEntriesByRemoteRoomData

  • Get a list of entries based on a RemoteRoom data value.

    example

    remoteRoom.set("some_key", "some_val"); // store remoteRoom and then: store.getEntriesByRemoteRoomData({ some_key: "some_val" });

    Parameters

    • data: Record<string, unknown>

      The data values to retrieve based from.

    Returns Promise<RoomBridgeStoreEntry[]>

getEntryById

getLinkedMatrixRooms

  • getLinkedMatrixRooms(remoteId: string): Promise<MatrixRoom[]>

getLinkedRemoteRooms

  • getLinkedRemoteRooms(matrixId: string): Promise<RemoteRoom[]>

getMatrixRoom

  • getMatrixRoom(roomId: string): Promise<undefined | null | MatrixRoom>
  • Get an entry's Matrix room based on the provided room_id. The entry MUST have an 'id' of the room_id and there MUST be a Matrix room contained within the entry for this to return.

    see

    RoomBridgeStore#setMatrixRoom

    Parameters

    • roomId: string

    Returns Promise<undefined | null | MatrixRoom>

insert

  • insert(objects: unknown): Promise<any[]>

insertIfNotExists

  • insertIfNotExists(query: Query, insertObj: Record<string, unknown>): Promise<void>

linkRooms

  • linkRooms(matrixRoom: MatrixRoom, remoteRoom: RemoteRoom, data?: Record<string, unknown>, linkId?: string): Promise<void>
  • Create a link between a matrix room and remote room. This will create an entry with:

    • The matrix_id set to the matrix room ID.
    • The remote_id set to the remote room ID.
    • The id set to the id value given OR a concatenation of the matrix and remote IDs if one is not provided.

    Parameters

    • matrixRoom: MatrixRoom

      The matrix room

    • remoteRoom: RemoteRoom

      The remote room

    • data: Record<string, unknown> = {}

      Information about this mapping.

    • Optional linkId: string

      The id value to set. If not given, a unique ID will be created from the matrix_id and remote_id.

    Returns Promise<void>

removeEntriesByLinkData

  • removeEntriesByLinkData(data: Record<string, unknown>): Promise<number>
  • Remove entries based on the link's data value.

    example

    store.linkRooms(matrixRoom, remoteRoom, { a_key: "a_val" }); store.removeEntriesByLinkData({ a_key: "a_val" });

    Parameters

    • data: Record<string, unknown>

      The data to match.

    Returns Promise<number>

removeEntriesByMatrixRoomData

  • removeEntriesByMatrixRoomData(data: Record<string, unknown>): Promise<number>
  • Remove entries based on matrix room data.

    example

    matrixRoom.set("a_key", "a_val"); // store matrixRoom and then: store.removeEntriesByMatrixRoomData({ a_key: "a_val" });

    Parameters

    • data: Record<string, unknown>

      The data to match.

    Returns Promise<number>

removeEntriesByMatrixRoomId

  • removeEntriesByMatrixRoomId(matrixId: string): Promise<number>
  • Remove entries with this matrix room id.

    example

    new MatrixRoom("!foobar:matrix.org"); // store the MatrixRoom and then: store.removeEntriesByMatrixRoomId("!foobar:matrix.org");

    Parameters

    • matrixId: string

      The matrix id.

    Returns Promise<number>

removeEntriesByRemoteRoomData

  • removeEntriesByRemoteRoomData(data: Record<string, unknown>): Promise<number>
  • Remove entries based on remote room data.

    example

    remoteRoom.set("a_key", "a_val"); // store remoteRoom and then: store.removeEntriesByRemoteRoomData({ a_key: "a_val" });

    Parameters

    • data: Record<string, unknown>

      The data to match.

    Returns Promise<number>

removeEntriesByRemoteRoomId

  • removeEntriesByRemoteRoomId(remoteId: string): Promise<number>
  • Remove entries with this remote room id.

    example

    new RemoteRoom("foobar"); // store the RemoteRoom and then: store.removeEntriesByRemoteRoomId("foobar");

    Parameters

    • remoteId: string

      The remote id.

    Returns Promise<number>

removeEntryById

  • removeEntryById(id: string): Promise<number>
  • Remove an existing entry based on the provided entry ID.

    example

    store.removeEntryById("anid");

    Parameters

    • id: string

      The ID of the entry to remove.

    Returns Promise<number>

select

  • select<T, O>(query: Query, transformFn?: (input: T) => O): Promise<O[]>

selectOne

  • selectOne<T, O>(query: Query, transformFn?: (input: T) => O): Promise<null | O>

setMatrixRoom

  • setMatrixRoom(matrixRoom: MatrixRoom): Promise<void>
  • Create an entry with only a matrix room. Sets the 'id' of the entry to the Matrix room ID. If an entry already exists with this 'id', it will be replaced. This function is useful if you just want to store a room with some data and not worry about any mappings.

    see

    RoomBridgeStore#getMatrixRoom

    Parameters

    Returns Promise<void>

setUnique

  • setUnique(fieldName: string, sparse?: boolean): void
  • Set a UNIQUE key constraint on the given field.

    Parameters

    • fieldName: string

      The field name. Use dot notation for nested objects.

    • sparse: boolean = false

      Allow sparse entries (undefined won't cause a key violation).

    Returns void

update

  • update(query: Query, updateVals: Record<string, unknown>): Promise<void>

upsert

  • upsert<T>(query: Query, updateVals: T): Promise<void>

upsertEntry

Static createUniqueId

  • createUniqueId(matrixRoomId: string, remoteRoomId: string, delimiter: string): string

Generated using TypeDoc