Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 21x 21x 21x 21x 6x 6x 6x 3x 3x 3x 3x 3x 3x 3x 3x 3x 6x 6x 21x 21x 21x 21x 6x 6x 6x 6x 6x 6x 6x 21x 21x 21x | const Streamz = require('streamz');
const Promise = require('bluebird');
const util = require('util');
function Insert(_c,collection,options) {
if (!(this instanceof Streamz))
return new Insert(_c,collection);
if (isNaN(_c)) {
options = collection;
collection = _c;
_c = undefined;
}
Streamz.call(this, _c, null, options);
this.collection = Promise.resolve(collection);
this.options = options || {};
}
util.inherits(Insert,Streamz);
Insert.prototype._fn = function (d) {
const operation = Array.isArray(d) ? 'insertMany' : 'insertOne';
return this.collection
.then(collection =>collection[operation](d,this.options))
.then(d => {
if (this.options.pushResults)
return d;
});
};
module.exports = Insert; |