Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace DB

Database operation.

There are two pools of data for each plugin: PluginSpace and ProfileSpace

If refid is a string, query will match a specific profile data in ProfileSpace.

If refid is null, query will match all profile data in ProfileSpace. (doesn't apply to DB.Insert)

If refid is not provided, query will match data in PluginSpace.


NOTE: since WebUI can delete data in ProfileSpace, you should refrain from referencing refid in your document to prevent getting unclearable garbage data.

If you need to make rival/friend feature, we recommend you to get all profile data by passing null to refid. There will be 16 profiles maximum which is small enough to manage.

Index

Functions

Count

  • Count<T>(refid: string | null, query: Query<T>): Promise<number>
  • Count<T>(query: Query<T>): Promise<number>
  • Type parameters

    • T

    Parameters

    • refid: string | null
    • query: Query<T>

    Returns Promise<number>

  • Type parameters

    • T

    Parameters

    • query: Query<T>

    Returns Promise<number>

Find

  • Find<T>(refid: string | null, query: Query<T>): Promise<Doc<T>[]>
  • Find<T>(query: Query<T>): Promise<Doc<T>[]>
  • Type parameters

    • T

    Parameters

    • refid: string | null
    • query: Query<T>

    Returns Promise<Doc<T>[]>

  • Type parameters

    • T

    Parameters

    • query: Query<T>

    Returns Promise<Doc<T>[]>

FindOne

  • FindOne<T>(refid: string | null, query: Query<T>): Promise<Doc<T>>
  • FindOne<T>(query: Query<T>): Promise<Doc<T>>
  • Type parameters

    • T

    Parameters

    • refid: string | null
    • query: Query<T>

    Returns Promise<Doc<T>>

  • Type parameters

    • T

    Parameters

    • query: Query<T>

    Returns Promise<Doc<T>>

Insert

  • Insert<T>(refid: string, doc: T): Promise<Doc<T>>
  • Insert<T>(doc: T): Promise<Doc<T>>

Remove

  • Remove<T>(refid: string | null, query: Query<T>): Promise<number>
  • Remove<T>(query: Query<T>): Promise<number>
  • Type parameters

    • T

    Parameters

    • refid: string | null
    • query: Query<T>

    Returns Promise<number>

  • Type parameters

    • T

    Parameters

    • query: Query<T>

    Returns Promise<number>

Update

  • Update<T>(refid: string | null, query: Query<T>, update: Update<T>): Promise<{ docs: Doc<T>[]; updated: number }>
  • Update<T>(query: Query<T>, update: Update<T>): Promise<{ docs: Doc<T>[]; updated: number }>
  • Type parameters

    • T

    Parameters

    • refid: string | null
    • query: Query<T>
    • update: Update<T>

    Returns Promise<{ docs: Doc<T>[]; updated: number }>

  • Type parameters

    • T

    Parameters

    • query: Query<T>
    • update: Update<T>

    Returns Promise<{ docs: Doc<T>[]; updated: number }>

Upsert

  • Upsert<T>(refid: string | null, query: Query<T>, update: Update<T>): Promise<{ docs: Doc<T>[]; updated: number; upsert: boolean }>
  • Upsert<T>(query: Query<T>, update: Update<T>): Promise<{ docs: Doc<T>[]; updated: number; upsert: boolean }>
  • Type parameters

    • T

    Parameters

    • refid: string | null
    • query: Query<T>
    • update: Update<T>

    Returns Promise<{ docs: Doc<T>[]; updated: number; upsert: boolean }>

  • Type parameters

    • T

    Parameters

    • query: Query<T>
    • update: Update<T>

    Returns Promise<{ docs: Doc<T>[]; updated: number; upsert: boolean }>

Generated using TypeDoc