Node.js Gridfs在不同的存储桶中找不到文件

Node.js Gridfs在不同的存储桶中找不到文件,node.js,mongodb,mongoose,gridfs,gridfs-stream,Node.js,Mongodb,Mongoose,Gridfs,Gridfs Stream,我已将文件添加到集合my_collections中 我无法检查文件是否已保存 对于默认的bucket fs.chunk和fs.files,下面的代码可以正常工作 db.my_collection.files.find() { "_id" : ObjectId("50e03d29edfdc00d34000001"), "filename" : "hd.txt", "contentType" : "plain/text", "length" : 85, "chunkSize" : 1024, "u

我已将文件添加到集合my_collections中

我无法检查文件是否已保存

对于默认的bucket fs.chunk和fs.files,下面的代码可以正常工作

db.my_collection.files.find()

{ "_id" : ObjectId("50e03d29edfdc00d34000001"), "filename" : "hd.txt", "contentType" : "plain/text", "length" : 85, "chunkSize" : 1024, "uploadDate" : ISODate("2014-10-29T06:57:42.375Z"), "aliases" : null, "metadata" : {  }, "md5" : "dc20cdc19005d04b8c36a889128170a8" }
代码:

该文件显示在db.my_collection.files中,但代码显示该文件不存在

如果删除root选项,同样的代码也可以工作

我想使用多个bucket,如中所述


有什么建议吗?

问题出在版本中。 github上的代码是最新的0.5.3 而在npm上则为0.5.1

所以我已经从github手动下载,一切正常。

var conn = mongoose.createConnection('localhost', 'testgridfs');
conn.once('open', function () {
var gfs = Grid(conn.db, mongoose.mongo);


  var options =  {
    _id: '50e03d29edfdc00d34000001', // a MongoDb ObjectId
    filename: 'hd.txt', // a filename
    mode: 'w',
    chunkSize: 1024,
    content_type: 'plain/text',
    root: 'my_collection',//<<<<< **if i comment it ,default collection is taken and codee works fine**
    metadata: {}
  }



  // write (this works in both default and custom bucket case)
  // var writestream = gfs.createWriteStream(options);
  // fs.createReadStream('/home/pop/Downloads/hd.txt').pipe(writestream);


  //chk exits or not
  gfs.exist(options  , function (err, found) {
    if (err) return handleError(err);
      found ? console.log('File exists') : console.log('File does not exist');
    });  
})