Closed Neewd closed 7 years ago
You seem to be passing the connection
object to the Grid
constructor, which according to the examples should be provided with the db
object that can be accesible, in your code, at conn.db
.
Maybe this is the cause?
Oh thanks you very much.
It seems I tried in the first place and that wasn't working so I just left this solution but maybe it was not working for some other reason.
TY !
Wow, I was doing the exact same thing and it was causing a whole host of problems.
I have some boiler plate express code that I had been using that looks like:
mongoose.connect(dbURL);
const db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function() {
...
const gfs = Grid(db, mongoose.mongo); // BAD!!!
const gfs = Grid(db.db, mongoose.mongo); // Terrible variable names but works
});
However my db
variable was actually just a mongoose.connection
object and thus I was passing that to the Grid
constructor.
Using db.db
(or better yet some sensible variable names solves the problem).
Thanks!
Hello,
It's my first time using gridfs with mongoose and I just followed the steps from the guide. But when I upload my picture my
is never called.
Here is my entire code.
When I set the writestream.on('error' , function() ...) nothing is happening too ...
What I did wrong ?