gridfs-stream icon indicating copy to clipboard operation
gridfs-stream copied to clipboard

Cannot read property 'topology' of undefined

Open stelapo opened this issue 8 years ago • 3 comments

Hi. I'm new with node, so i could write wrong code.

I'm trying to read a file saved into collection "fs.files". My code is:

var readstream = gfs.createReadStream({ _id: file_id, readPreference: 'secondaryPreferred', w: -1 });

I obtaing this error: **node_modules/mongodb/lib/gridfs/grid_store.js:205 return executeOperation(this.db.s.topology, open, [this, options, callback], { ^

TypeError: Cannot read property 'topology' of undefined**

Could someone give me help? Thanx

stelapo avatar Mar 06 '18 15:03 stelapo

same here

alphonsoTheGreat avatar May 14 '18 15:05 alphonsoTheGreat

Same but when trying to use gfs.remove({ _id: mongoose.mongo.ObjectId(req.params.id)})

caseychoiniere avatar Jul 19 '18 20:07 caseychoiniere

I am facing the same issue and any solution for this?

let gfs;

const conn = mongoose.connection;    
conn.options = {};    
conn.once('open',  ()  => {    
  gfs = Grid(mongoose.connection, mongoose.mongo);  
  gfs.collection('uploads');

});

router.get('/image/:filename', getFile)

function getFile(req, res, next) 
{
   var readstream = gfs.createReadStream(req.params.filename);

   readstream.pipe(res)
}

mbharanidharan88 avatar Jul 22 '19 16:07 mbharanidharan88