7
Gulp
Veritabanımı, Gulp Data kullanırken, veri kaynağı olarak Mongo
veritabanından nasıl alabilirim?Gulp Veriyi Kullanma Gulp Data kullanarak Gulp Veri
Gulp Görev ( basitleştirilmiş)
Ben prototip veritabanını kullanıyorumgulp.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);
cb(undefined, db.collection('heroes').findOne()); // <--This doesn't work.
});
}))
//.pipe(data({"title":"this works"})) -> This does work
.pipe(through.obj(function(file,enc,cb){console.log('file.data:'+JSON.stringify(file.data,null,2))}));
});
, ben çalıştırabilir,
> db.heroes.findOne()
Ve bu sonuç almak:
{
"_id" : ObjectId("581f9a71a829f911264ecba4"),
"title" : "This is the best product!"
}