Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MongoPortable

MongoPortable

module

MongoPortable

since

0.0.1

classdesc

Portable database with persistence and MongoDB-like API

param

Name of the database.

Hierarchy

Index

Constructors

constructor

  • new MongoPortable(databaseName: string, options: any): MongoPortable

Properties

Private _collections

_collections: __type

Private _databaseName

_databaseName: string

Private _stores

_stores: Array<Object | Function>

createCollection

createCollection: collection = this.collection

Alias for {@link MongoPortable#collection}

method

MongoPortable#createCollection

Protected logger

logger: JSWLogger

pkFactory

pkFactory: any

Static Private _connHelper

_connHelper: ConnectionHelper = new ConnectionHelper()

Methods

addStore

  • addStore(store: any): this
  • Adds a custom stores for remote and local persistence

    Parameters

    • store: any

      The custom store

    Returns this

    this - The current Instance

collection

  • collection(collectionName: any, options: any, callback?: any): Promise<Collection>
  • Creates a collection on a server pre-allocating space, need to create f.ex capped collections.

    method

    MongoPortable#collection

    fires

    {@link MongoStore#createCollection}

    Parameters

    • collectionName: any

      the collection name we wish to access.

    • options: any
    • Optional callback: any

    Returns Promise<Collection>

collectionNames

  • collectionNames(options: any, callback?: any): Array<any>
  • Get the list of all collection names for the specified db, by calling MongoPortable#collections with [options.namesOnly = true]

    method

    MongoPortable#collectionNames

    Parameters

    • options: any
    • Optional callback: any

    Returns Array<any>

    {@link MongoPortable#collections}

collections

  • collections(options: any, callback?: any): Array<any>
  • Get the list of all collection for the specified db

    method

    MongoPortable#collections

    Parameters

    • options: any
    • Optional callback: any

    Returns Array<any>

collectionsInfo

  • collectionsInfo(collectionName: any, callback?: any): void
  • Returns a cursor to all the collection information.

    todo

    Implement

    Parameters

    • collectionName: any
    • Optional callback: any

    Returns void

createIndex

  • createIndex(collectionName: any, fieldOrSpec: any, options: any, callback: any): void
  • Creates an index on the collection.

    method

    MongoPortable#createIndex

    todo

    Implement

    Parameters

    • collectionName: any

      Name of the collection to create the index on.

    • fieldOrSpec: any

      FieldOrSpec that defines the index.

    • options: any
    • callback: any

    Returns void

dereference

  • dereference(dbRef: any, callback: any): void
  • Dereference a dbref, against a db

    todo

    Implement

    ignore

    Parameters

    • dbRef: any

      db reference object we wish to resolve.

    • callback: any

    Returns void

dropCollection

  • dropCollection(collectionName: any, callback?: any): Promise<Boolean>
  • Drop a collection from the database, removing it permanently. New accesses will create a new collection.

    method

    MongoPortable#dropCollection

    Parameters

    • collectionName: any

      The name of the collection we wish to drop.

    • Optional callback: any

    Returns Promise<Boolean>

    Promise with "true" if dropped successfully

dropDatabase

  • dropDatabase(callback?: any): Promise<Boolean>
  • Drop the whole database.

    method

    MongoPortable#dropDatabase

    Parameters

    • Optional callback: any

    Returns Promise<Boolean>

    Promise with "true" if dropped successfully

dropIndex

  • dropIndex(collectionName: any, indexName: any, callback: any): void
  • Drop an index on a collection.

    method

    MongoPortable#dropIndex

    todo

    Implement

    Parameters

    • collectionName: any

      The name of the collection where the command will drop an index.

    • indexName: any

      Name of the index to drop.

    • callback: any

    Returns void

emit

  • emit(name: string, args: Object): Promise<void>

ensureIndex

  • ensureIndex(collectionName: any, fieldOrSpec: any, options: any, callback: any): void
  • Ensures that an index exists, if it does not it creates it

    method

    MongoPortable#ensureIndex

    todo

    Implement

    Parameters

    • collectionName: any

      Name of the collection to create the index on.

    • fieldOrSpec: any

      FieldOrSpec that defines the index.

    • options: any
    • callback: any

    Returns void

fetchCollections

  • fetchCollections(options: any, callback?: any): Array<any>
  • Alias for {@link MongoPortable#collections}

    method

    MongoPortable#fetchCollections

    Parameters

    • options: any
    • Optional callback: any

    Returns Array<any>

indexInformation

  • indexInformation(collectionName: any, options: any, callback: any): void
  • Retrieves this collections index info.

    method

    MongoPortable#indexInformation

    todo

    Implement

    Parameters

    • collectionName: any

      The name of the collection.

    • options: any
    • callback: any

    Returns void

reIndex

  • reIndex(collectionName: any, callback: any): void
  • Reindex all indexes on the collection Warning: "reIndex" is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.

    method

    MongoPortable#reIndex

    todo

    Implement

    Parameters

    • collectionName: any

      The name of the collection to reindex

    • callback: any

    Returns void

renameCollection

  • renameCollection(fromCollection: any, toCollection: any, callback?: any): Promise<Collection>
  • Rename a collection.

    method

    MongoPortable#renameCollection

    Parameters

    • fromCollection: any

      The name of the current collection we wish to rename.

    • toCollection: any

      The new name of the collection.

    • Optional callback: any

    Returns Promise<Collection>

    Promise with the renamed collection

use

  • use(name: any, obj: any): void
  • Middleware functions

    Parameters

    • name: any

      Name of the middleware:

      • "store": Add a custom store

    • obj: any

    Returns void

Static getInstance

Object literals

options

options: object

log

log: object

Type declaration

Generated using TypeDoc