find-and-modify-stream
MongoDB find and modify object write stream
Installation
npm install find-and-modify-stream --save
Usage
var MongoStream = var MongoClient = MongoClient MongoClient
var writeStream = MongoStream(options)
Options must include:
connection
- a database connection returned fromMongoClient.connect
collection
- the collection name to perform the operation on
Optional options:
query
- a function used to construct the query for thefindAndModify
operation. Defaults to:function (obj) { return { _id: obj._id }}
queryOptions
- an object of options passed to thefindAndModify
operation. Can be used to modify write concerns and upsert preferences. Defaults to:{ upsert: true, w: 1, fsync: true }
Credits
Dom Harrington follow me on twitter @domharrington