Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

Properties

Readonly db

db: Nedb<any>

Methods

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: Record<string, unknown>): 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<null | string[]>
  • 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.

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<null | string[]>
  • 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.

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: Record<string, unknown>, 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<void>

select

  • select<T, O>(query: Record<string, unknown>, transformFn?: (input: T) => O): Promise<O[]>
  • SELECT a number of documents.

    Type parameters

    • T

    • O

    Parameters

    • query: Record<string, unknown>
    • Optional transformFn: (input: T) => O
        • (input: T): O
        • Parameters

          • input: T

          Returns O

    Returns Promise<O[]>

selectOne

  • selectOne<T, O>(query: Record<string, unknown>, transformFn?: (input: T) => O): Promise<null | O>
  • SELECT a single document.

    Type parameters

    • T

    • O

    Parameters

    • query: Record<string, unknown>
    • Optional transformFn: (input: T) => O
        • (input: T): O
        • Parameters

          • input: T

          Returns O

    Returns Promise<null | O>

setMatrixUser

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

setRemoteUser

  • setRemoteUser(remoteUser: RemoteUser): 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

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: Record<string, unknown>, updateVals: Record<string, unknown>): Promise<void>
  • UPDATE a single document. If the document already exists, this will NOT update it.

    Parameters

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

    Returns Promise<void>

upsert

  • upsert<T>(query: Record<string, unknown>, updateVals: T): Promise<void>

Generated using TypeDoc