You can change the line cb(undefined, db.collection('heroes').findOne()); as shown below
db.collection('heroes').findOne(function(err, item) { cb(undefined, item); });
OR as shown below
db.collection('heroes').findOne(cb);
So your simplified Gulp task will be,
gulp.task('db-test', function() { return gulp.src('./examples/test3.html') .pipe(data(function(file, cb) { MongoClient.connect('mongodb://127.0.0.1:27017/prototype', function(err, db) { if(err) return cb(err); db.collection('heroes').findOne(cb); }); }))
Aruna
source share