Base class for bridge stores.

Hierarchy

Constructors

  • Construct a store suitable for user bridging information.

    Parameters

    • db: Nedb<any>

      The connected NEDB database instance

    Returns UserBridgeStore

Properties

db: Nedb<any>

Methods

  • Convenience method to convert a document to something.

    Returns

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

    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)

      • (doc: T): O
      • Parameters

        • doc: T

        Returns O

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

    Returns

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

    Throws

    If dataQuery isn't an object.

    Example

    matrixUser.set({
    toplevel: "foo",
    nested: {
    bar: {
    baz: 43
    }
    }
    });
    store.setMatrixUser(matrixUser).then(function() {
    store.getByMatrixData({
    "toplevel": "foo",
    "nested.bar.baz": 43
    })
    });

    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[]>

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

    Returns

    Resolves to a MatrixUser or null.

    Parameters

    • localpart: string

      The user localpart

    Returns Promise<null | MatrixUser>

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

    Returns

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

    Throws

    If dataQuery isn't an object.

    Example

    remoteUser.set({
    toplevel: "foo",
    nested: {
    bar: {
    baz: 43
    }
    }
    });
    store.setRemoteUser(remoteUser).then(function() {
    store.getByRemoteData({
    "toplevel": "foo",
    "nested.bar.baz": 43
    })
    });

    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[]>

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

    Returns

    A list of user IDs.

    Parameters

    • remoteId: string

      The remote ID

    Returns Promise<null | string[]>

  • Get a matrix user by their user ID.

    Returns

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

    Parameters

    • userId: string

      The user_id

    Returns Promise<null | MatrixUser>

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

    Returns

    Resolves to a list of Matrix users.

    Parameters

    • remoteId: string

      The Remote ID

    Returns Promise<MatrixUser[]>

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

    Returns

    A list of remote IDs.

    Parameters

    • matrixId: string

      The matrix user ID

    Returns Promise<null | string[]>

  • Get a remote user by their remote ID.

    Returns

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

    Parameters

    • id: string

      The remote ID

    Returns Promise<null | RemoteUser>

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

    Returns

    Resolves to a list of Remote users.

    Parameters

    • userId: string

      The Matrix user ID

    Returns Promise<RemoteUser[]>

  • 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
    • Optional transformFn: ((input: T) => O)
        • (input: T): O
        • Parameters

          • input: T

          Returns O

    Returns Promise<O[]>

  • SELECT a single document.

    Type Parameters

    • T

    • O

    Parameters

    • query: Query
    • Optional transformFn: ((input: T) => O)
        • (input: T): O
        • Parameters

          • input: T

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

    Returns

    Resolves to the number of entries removed.

    Parameters

    • matrixUserId: string

      The matrix user ID

    • remoteUserId: string

      The remote user ID

    Returns Promise<number>

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

    Returns

    Resolves to the number of entries removed.

    Parameters

    Returns Promise<number>

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

Generated using TypeDoc