Cannot read property 'topology' of undefined
Opened this issue · 3 comments
stelapo commented
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
alphonsoTheGreat commented
same here
caseychoiniere commented
Same but when trying to use gfs.remove({ _id: mongoose.mongo.ObjectId(req.params.id)})
mbharanidharan88 commented
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)
}