MongoPortable

module

  MongoPortable

since

  0.0.1

classdesc

  Portable database with persistence and MongoDB-like API

param

  Name of the database.

### Hierarchy

- EventEmitter
  - MongoPortable

## Index

### Constructors

- constructor

### Properties

- _collections
- _databaseName
- _stores
- createCollection
- logger
- pkFactory
- _connHelper

### Methods

- addStore
- collection
- collectionNames
- collections
- collectionsInfo
- createIndex
- dereference
- dropCollection
- dropDatabase
- dropIndex
- emit
- ensureIndex
- fetchCollections
- indexInformation
- reIndex
- renameCollection
- use
- getInstance

### Object literals

- options

## Constructors

### constructor

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

- Overrides EventEmitter.constructor

  - Defined in core/MongoPortable.ts:40

  #### Parameters

  - ##### databaseName: string

  - ##### options: any

  #### Returns MongoPortable

## Properties

### Private _collections

_collections: __type

- Defined in core/MongoPortable.ts:33

### Private _databaseName

_databaseName: string

- Defined in core/MongoPortable.ts:35

### Private _stores

_stores: Array<Object | Function>

- Defined in core/MongoPortable.ts:34

### createCollection

createCollection: collection = this.collection

- Defined in core/MongoPortable.ts:314

Alias for {@link MongoPortable#collection}

method

  MongoPortable#createCollection

### Protected logger

logger: JSWLogger

Overrides EventEmitter.logger

- Defined in core/MongoPortable.ts:31

### pkFactory

pkFactory: any

- Defined in core/MongoPortable.ts:40

### Static Private _connHelper

_connHelper: ConnectionHelper = new ConnectionHelper()

- Defined in core/MongoPortable.ts:37

## Methods

### addStore

- addStore(store: any): this

- - Defined in core/MongoPortable.ts:91

  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>

- - Defined in core/MongoPortable.ts:256

  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>

- - Defined in core/MongoPortable.ts:207

  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>

- - Defined in core/MongoPortable.ts:157

  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

- - Defined in core/MongoPortable.ts:130

  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

- - Defined in core/MongoPortable.ts:452

  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

- - Defined in core/MongoPortable.ts:585

  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>

- - Defined in core/MongoPortable.ts:326

  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>

- - Defined in core/MongoPortable.ts:548

  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

- - Defined in core/MongoPortable.ts:501

  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>

- Overrides EventEmitter.emit

  - Defined in core/MongoPortable.ts:63

  #### Parameters

  - ##### name: string

  - ##### args: Object

  #### Returns Promise<void>

### ensureIndex

- ensureIndex(collectionName: any, fieldOrSpec: any, options: any, callback: any): void

- - Defined in core/MongoPortable.ts:486

  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>

- - Defined in core/MongoPortable.ts:139

  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

- - Defined in core/MongoPortable.ts:535

  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

- - Defined in core/MongoPortable.ts:516

  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>

- - Defined in core/MongoPortable.ts:369

  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

- - Defined in core/MongoPortable.ts:76

  Middleware functions

  #### Parameters

  - ##### name: any

    Name of the middleware:

    - "store": Add a custom store

  - ##### obj: any

  #### Returns void

### Static getInstance

- getInstance(name: string): Connection

- - Defined in core/MongoPortable.ts:112

  Retrieves the instance of that DDBB name

  #### Parameters

  - ##### name: string

    The DDBB name

  #### Returns Connection

  - The DDBB instance

## Object literals

### options

options: object

Inherited from EventEmitter.options

- Defined in emitter/EventEmitter.ts:7

### log

log: object

- Defined in emitter/EventEmitter.ts:8

#### Type declaration

Generated using TypeDoc