Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Mongol

MongoDB helpers class.

Hierarchy

  • Mongol

Index

Constructors

constructor

Accessors

database

  • get database(): Db
  • Database instance.

    In upcoming minor versions, this will be deprecated. In the next major version, this will be removed.

    Returns Db

promisifiedDatabase

  • get promisifiedDatabase(): Promise<Db>
  • Database instance, as a Promise.

    Returns Promise<Db>

Methods

attachDatabaseHook

  • Attach a database hook to a collection.

    Type parameters

    • TSchema

    • TArgs: any[]

    • TResult

    Parameters

    • collection: Collection<TSchema>

      Collection.

    • hook: DatabaseHook<TArgs, TResult>

      Database hook/trigger.

    Returns ExtendedCollection<TSchema>

    Collection with the hook attached.

collection

connect

  • connect(): Promise<void>
  • Connect to the database.

    In upcoming minor versions, this will do nothing. In the next major version, this will be removed.

    Returns Promise<void>

disconnect

  • disconnect(): Promise<void>
  • Disconnect from the database.

    In upcoming minor versions, this will do nothing. In the next major version, this will be removed.

    Returns Promise<void>

promisifiedCollection

  • promisifiedCollection<TSchema>(collectionName: string): Promise<ExtendedCollection<TSchema>>
  • Fetch a specific collection, as a Promise.

    Type parameters

    • TSchema

    Parameters

    • collectionName: string

      Collection name.

    Returns Promise<ExtendedCollection<TSchema>>

setSchema

  • setSchema(collectionName: string, schema: object, options?: SchemaOptions): Promise<object>
  • Add or update JSON schema of a collection.

    Parameters

    • collectionName: string

      Collection name.

    • schema: object

      JSON schema.

    • Default value options: SchemaOptions = {}

      Options.

    Returns Promise<object>

    Actually used JSON schema.