Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Collection

Hierarchy

  • Collection

Index

Constructors

constructor

  • new Collection(db: any, collectionName: any): Collection

Properties

databaseName

databaseName: any

doc_indexes

doc_indexes: any

docs

docs: any

emit

emit: function

Type declaration

    • (name: string, args: object): Promise<void>
    • Parameters

      • name: string
      • args: object

      Returns Promise<void>

fullName

fullName: any

Protected logger

logger: JSWLogger

name

name: any

snapshots

snapshots: any

Methods

aggregate

  • aggregate(pipeline: any, options?: object): any
  • Calculates aggregate values for the data in a collection

    method

    Collection#aggregate

    Parameters

    • pipeline: any

      A sequence of data aggregation operations or stages

    • Default value options: object = { forceFetch: false }
      • forceFetch: boolean

    Returns any

    If "options.forceFetch" set to true returns the array of documents, otherwise returns a cursor

backup

  • backup(backupID: any, callback?: any): Promise<any>

backups

  • backups(): any[]

bulkInsert

  • bulkInsert(docs: any, options: any, callback?: any): ThenPromise<Object>
  • Inserts several documents into the collection

    Parameters

    • docs: any

      Documents to be inserted

    • options: any
    • Optional callback: any

    Returns ThenPromise<Object>

    Returns a promise with the inserted documents

clearBackups

  • clearBackups(): void

delete

  • delete(selection: any, options: any, callback?: any): Promise<any[]>
  • Alias for {@link Collection#remove}

    method

    Collection#delete

    Parameters

    • selection: any
    • options: any
    • Optional callback: any

    Returns Promise<any[]>

destroy

  • destroy(selection: any, options: any, callback?: any): Promise<any[]>
  • Alias for {@link Collection#remove}

    method

    Collection#destroy

    Parameters

    • selection: any
    • options: any
    • Optional callback: any

    Returns Promise<any[]>

drop

  • drop(options: any, callback?: any): Promise<any[]>
  • Drops a collection

    method

    Collection#drop

    Parameters

    • options: any
    • Optional callback: any

    Returns Promise<any[]>

    Promise with the deleted documents

ensureIndex

  • ensureIndex(): void

find

  • find(selection: any, fields: any, options: any, callback?: any): Promise<any[] | Cursor>
  • Finds all matching documents

    method

    Collection#find

    Parameters

    • selection: any
    • fields: any
    • options: any
    • Optional callback: any

    Returns Promise<any[] | Cursor>

    Returns a promise with the documents (or cursor if "options.forceFetch" set to true)

findOne

  • findOne(selection: any, fields: any, options: any, callback?: any): Promise<any>
  • Finds the first matching document

    method

    Collection#findOne

    Parameters

    • selection: any
    • fields: any
    • options: any
    • Optional callback: any

    Returns Promise<any>

    Returns a promise with the first matching document of the collection

insert

  • insert(doc: any, options: any, callback?: any): Promise<any>
  • Inserts a document into the collection

    method

    Collection#insert

    Parameters

    • doc: any

      Document to be inserted

    • options: any
    • Optional callback: any

    Returns Promise<any>

    Returns a promise with the inserted document

remove

  • remove(selection: any, options: any, callback?: any): Promise<any[]>
  • Removes one or many documents

    method

    Collection#remove

    Parameters

    • selection: any
    • options: any
    • Optional callback: any

    Returns Promise<any[]>

    Promise with the deleted documents

removeBackup

  • removeBackup(backupID: any): string

rename

  • rename(newName: any): this

restore

  • restore(backupID: any, callback: any): Promise<string>

save

  • save(doc: any, options: any, callback?: any): Promise<any>
  • Insert or update a document. If the document has an "_id" is an update (with upsert), if not is an insert.

    method

    Collection#save

    Parameters

    • doc: any

      Document to be inserted/updated

    • options: any
    • Optional callback: any

    Returns Promise<any>

    Returns a promise with the inserted document or the update information

update

  • update(selection: any, update: any, options: any, callback?: any): Promise<any>
  • Updates one or many documents

    method

    Collection#update

    Parameters

    • selection: any
    • update: any
    • options: any
    • Optional callback: any

    Returns Promise<any>

    Returns a promise with the update/insert (if upsert=true) information

Static checkCollectionName

  • checkCollectionName(collectionName: any): void

Object literals

Static _noCreateModifiers

_noCreateModifiers: object
ignore

$pop

$pop: boolean = true

$pull

$pull: boolean = true

$pullAll

$pullAll: boolean = true

$rename

$rename: boolean = true

$unset

$unset: boolean = true

Generated using TypeDoc