Module: CollectionAdd

CollectionAdd factory.
Mixes In:
  • Inserting
  • Query
Source:

Methods

add(input) → {module:CollectionAdd}

Create query to add one or various documents.
Parameters:
Name Type Description
input Object | Array.<Object> document or list of documents
Source:
Throws:
When the input type is invalid.
Type
Error
Returns:
The query instance.
Type
module:CollectionAdd
Example
// arguments as single documents
collection.add({ foo: 'baz' }).add({ bar: 'qux' }, { biz: 'quux' })

// array of documents
collection.add([{ foo: 'baz' }]).add([{ bar: 'qux' }, { biz: 'quux' }])

execute() → {Promise.<module:Result>}

Run the query to save the documents to the collection in the database. If a document does not contain an _id, it will be assigned a UUID-like value.
Source:
Tutorials:
Returns:
Type
Promise.<module:Result>

Type Definitions

CollectionAddOptions

Type:
  • Object
Properties:
Name Type Description
upsert boolean upsert query
Source: