Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

Properties

Readonly db

db: Datastore

Methods

convertTo

  • convertTo<T, O>(func: (input: T) => O): (Anonymous function)
  • 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 (Anonymous function)

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

delete

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

getByMatrixData

  • getByMatrixData(dataQuery: Record<string, unknown>): Promise<MatrixUser[]>
  • Get Matrix users by some data about them, previously stored via the set method on the Matrix user.

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

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

getByMatrixLocalpart

  • getByMatrixLocalpart(localpart: string): Promise<null | 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.

    Parameters

    • localpart: string

      The user localpart

    Returns Promise<null | MatrixUser>

    Resolves to a MatrixUser or null.

getByRemoteData

  • getByRemoteData(dataQuery: Record<string, unknown>): Promise<RemoteUser[]>
  • Get remote users by some data about them, previously stored via the set method on the Remote user.

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

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

getMatrixLinks

  • getMatrixLinks(remoteId: string): Promise<string[] | null>
  • Retrieve a list of matrix user IDs linked to this remote ID.

    Parameters

    • remoteId: string

      The remote ID

    Returns Promise<string[] | null>

    A list of user IDs.

getMatrixUser

  • getMatrixUser(userId: string): Promise<null | MatrixUser>
  • 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.

getMatrixUsersFromRemoteId

  • getMatrixUsersFromRemoteId(remoteId: string): Promise<MatrixUser[]>

getRemoteLinks

  • getRemoteLinks(matrixId: string): Promise<string[] | null>
  • Retrieve a list of remote IDs linked to this matrix user ID.

    Parameters

    • matrixId: string

      The matrix user ID

    Returns Promise<string[] | null>

    A list of remote IDs.

getRemoteUser

  • getRemoteUser(id: string): Promise<null | RemoteUser>
  • 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.

getRemoteUsersFromMatrixId

  • getRemoteUsersFromMatrixId(userId: string): Promise<RemoteUser[]>

insert

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

insertIfNotExists

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

linkUsers

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

select

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

selectOne

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

setMatrixUser

  • setMatrixUser(matrixUser: MatrixUser): Promise<number>

setRemoteUser

  • setRemoteUser(remoteUser: RemoteUser): Promise<number>

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.

    • Default value sparse: boolean = false

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

    Returns void

unlinkUserIds

  • unlinkUserIds(matrixUserId: string, remoteUserId: string): Promise<number>
  • 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.

unlinkUsers

update

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

upsert

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

Generated using TypeDoc