Options
All
  • Public
  • Public/Protected
  • All
Menu

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

All query and doc should not have any fields start with __ while __refid being the only exception. However, __refid field will still be ignored while other __ starting fields will cause an error to be thrown.

Index

Functions

  • Count<T>(refid: string, query: Query<T>): Promise<number>
  • Count<T>(query: Query<T>): Promise<number>
  • Find<T>(refid: string, query: Query<T>): Promise<ProfileDoc<T>[]>
  • Find<T>(query: Query<T>): Promise<Doc<T>[]>
  • FindOne<T>(refid: string, query: Query<T>): Promise<ProfileDoc<T>>
  • FindOne<T>(query: Query<T>): Promise<Doc<T>>
  • Insert<T>(refid: string, doc: T): Promise<ProfileDoc<T>>
  • Insert<T>(doc: T): Promise<Doc<T>>
  • Remove<T>(refid: string, query: Query<T>): Promise<number>
  • Remove<T>(query: Query<T>): Promise<number>
  • Update<T>(refid: string, query: Query<T>, update: Update<T>): Promise<{ docs: ProfileDoc<T>[]; updated: number }>
  • Update<T>(query: Query<T>, update: Update<T>): Promise<{ docs: Doc<T>[]; updated: number }>
  • Type parameters

    • T

    Parameters

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

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

  • Type parameters

    • T

    Parameters

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

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

  • Upsert<T>(refid: string, query: Query<T>, update: Update<T>): Promise<{ docs: ProfileDoc<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
    • query: Query<T>
    • update: Update<T>

    Returns Promise<{ docs: ProfileDoc<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