Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'topology' of undefined #130

Open
stelapo opened this issue Mar 6, 2018 · 3 comments
Open

Cannot read property 'topology' of undefined #130

stelapo opened this issue Mar 6, 2018 · 3 comments

Comments

@stelapo
Copy link

stelapo commented Mar 6, 2018

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
Copy link

same here

@caseychoiniere
Copy link

caseychoiniere commented Jul 19, 2018

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

@mbharanidharan88
Copy link

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)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants