Tuesday, 18 April 2017

No fs.chunks present in Mongodb?

I inserted file in GridFS using code

  conn.once('open', function(){
  console.log('-- connection open --');
  var gfs = Grid(conn.db);
  var writestream = gfs.createWriteStream({
    filename: 'basic.txt'
  });
  fs.createReadStream(filepath).pipe(writestream);
  writestream.on('close', function(file){
    console.log(file.filename + "Written into Db");
  });
});

from shell when I run command

db.fs.files.find()

I found basic.txt but when I run command

db.fs.chunks.find({"_id" : ObjectId("58f5ef2095c76333d8ecc782")})

here _id is id of basic.txt in mongodb. it shows nothing in return, help me with this?



via AviatorX

No comments:

Post a Comment