CollectionAdd factory.
- Mixes In:
- Inserting
- Query
Methods
-
add(input)
-
Create query to add one or various documents.
Parameters:
Name Type Description input
Object | Array.<Object> document or list of documents 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()
-
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.- Tutorials:
Returns:
- Type
- Promise.<module:Result>
Type Definitions
-
CollectionAddOptions
-
Type:
- Object
Properties:
Name Type Description upsert
boolean upsert query