matrix-appservice-bridge
    Preparing search index...

    Class UserBridgeStore

    Base class for bridge stores.

    Hierarchy (View Summary)

    Index

    Constructors

    • Construct a store suitable for user bridging information.

      Parameters

      • db: Nedb

        The connected NEDB database instance

      Returns UserBridgeStore

    Properties

    db: Nedb

    Methods

    • 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.

      Returns (doc: T) => O

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

    • DELETE multiple documents.

      Parameters

      • query: Query

      Returns Promise<number>

    • Get Matrix users by some data about them, previously stored via the set method on the Matrix user.

      Parameters

      • dataQuery: Record<string, unknown>

        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" }

      Returns Promise<MatrixUser[]>

      Resolves to a possibly empty list of MatrixUsers. Rejects with an error if there was a problem querying the store.

      If dataQuery isn't an object.

      matrixUser.set({
      toplevel: "foo",
      nested: {
      bar: {
      baz: 43
      }
      }
      });
      store.setMatrixUser(matrixUser).then(function() {
      store.getByMatrixData({
      "toplevel": "foo",
      "nested.bar.baz": 43
      })
      });
    • 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

      • localpart: string

        The user localpart

      Returns Promise<null | MatrixUser>

      Resolves to a MatrixUser or null.

    • Get remote users by some data about them, previously stored via the set method on the Remote user.

      Parameters

      • dataQuery: Record<string, unknown>

        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" }

      Returns Promise<RemoteUser[]>

      Resolves to a possibly empty list of RemoteUsers. Rejects with an error if there was a problem querying the store.

      If dataQuery isn't an object.

      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

      • remoteId: string

        The remote ID

      Returns Promise<null | string[]>

      A list of user IDs.

    • Get a matrix user by their user ID.

      Parameters

      • userId: string

        The user_id

      Returns Promise<null | MatrixUser>

      Resolves to the user or null if they do not exist. Rejects with an error if there was a problem querying the store.

    • Retrieve a list of corresponding matrix users for the given remote ID.

      Parameters

      • remoteId: string

        The Remote ID

      Returns Promise<MatrixUser[]>

      Resolves to a list of Matrix users.

    • Retrieve a list of remote IDs linked to this matrix user ID.

      Parameters

      • matrixId: string

        The matrix user ID

      Returns Promise<null | string[]>

      A list of remote IDs.

    • Get a remote user by their remote ID.

      Parameters

      • id: string

        The remote ID

      Returns Promise<null | RemoteUser>

      Resolves to the user or null if they do not exist. Rejects with an error if there was a problem querying the store.

    • Retrieve a list of corresponding remote users for the given matrix user ID.

      Parameters

      • userId: string

        The Matrix user ID

      Returns Promise<RemoteUser[]>

      Resolves to a list of Remote users.

    • INSERT a multiple documents.

      Parameters

      • objects: unknown

      Returns Promise<any[]>

    • INSERT IF NOT EXISTS a single document

      Parameters

      • query: Query
      • insertObj: Record<string, unknown>

      Returns Promise<void>

    • 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

      Returns Promise<void>

    • SELECT a number of documents.

      Type Parameters

      • T
      • O

      Parameters

      • query: Query
      • OptionaltransformFn: (input: T) => O

      Returns Promise<O[]>

    • SELECT a single document.

      Type Parameters

      • T
      • O

      Parameters

      • query: Query
      • OptionaltransformFn: (input: T) => O

      Returns Promise<null | O>

    • Store a Matrix user. If they already exist, they will be updated. Equivalence is determined by their user ID.

      Parameters

      Returns Promise<void>

    • Store a Remote user. If they already exist, they will be updated. Equivalence is determined by the Remote ID.

      Parameters

      Returns Promise<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

    • Delete a link between a matrix user ID and a remote user ID.

      Parameters

      • matrixUserId: string

        The matrix user ID

      • remoteUserId: string

        The remote user ID

      Returns Promise<number>

      Resolves to the number of entries removed.

    • Delete a link between a matrix user and a remote user.

      Parameters

      Returns Promise<number>

      Resolves to the number of entries removed.

    • UPDATE a single document. If the document already exists, this will NOT update it.

      Parameters

      • query: Query
      • updateVals: Record<string, unknown>

      Returns Promise<void>

    • UPSERT a single document

      Type Parameters

      • T

      Parameters

      • query: Query
      • updateVals: T

      Returns Promise<void>