Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MongoDatabase

A MongoDB connection.

Hierarchy

  • MongoDatabase

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

Properties

Private _mongo

_mongo: Connection

Readonly options

Connection options.

Accessors

isConnected

  • get isConnected(): boolean
  • Gets if there is currently an open database connection or not.

    Returns boolean

mongo

  • get mongo(): Connection

Methods

connect

  • connect(): Promise<boolean>
  • Starts a connection to the server.

    Returns Promise<boolean>

    The promise, which indicates if operation was successful or not.

disconnect

  • disconnect(): Promise<boolean>
  • Closes the current connection.

    Returns Promise<boolean>

    The promise, which indicates if operation was successful or not.

model

  • model<T>(name: string): Model<T>
  • Returns a model by name.

    Type parameters

    • T: Document

    Parameters

    • name: string

      The name of the model.

    Returns Model<T>

    The model.

query

  • query<T>(schema: string, func: string, ...args: any[]): DocumentQuery<T[], T>
  • Starts a query for a schema and a list of results.

    Type parameters

    • T: Document

    Parameters

    • schema: string

      The name of the schema.

    • func: string

      The name of the initial function.

    • Rest ...args: any[]

    Returns DocumentQuery<T[], T>

    The query.

queryOne

  • queryOne<T>(schema: string, func: string, ...args: any[]): DocumentQuery<T, T>
  • Starts a query for a schema and a single result.

    Type parameters

    • T: Document

    Parameters

    • schema: string

      The name of the schema.

    • func: string

      The name of the initial function.

    • Rest ...args: any[]

    Returns DocumentQuery<T, T>

    The query.

schema

  • schema(name: string): Schema
  • Returns a schema by name.

    Parameters

    • name: string

      The name of the schema.

    Returns Schema

    The schema.

Generated using TypeDoc