Closed mxrguspxrt closed 9 years ago
@mxrguspxrt this issue drove me insane some few months back.
the misleading part in the gridfs-stream documentation is this bit
"Options may contain zero or more of the following options",
Actually that is not entirely true as excluding the "w" attribute in the createWriteStream options object will throw the error you are experiencing. Adding it should fix that as it did for me.
follow the below link for full details from the original source http://mongodb.github.io/node-mongodb-native/api-generated/gridstore.html
Hey!
Sorry, I think this can be closed. I rewrote. I was not using connection object, but db object, or some similar use case error.
I think there should be check that object is of correct type.
Code:
mongoose.connect("mongodb://localhost/comics"); var db = mongoose.connection; db.once('open', function() { // .. Grid.current = Grid(db, mongoose.mongo); });
var gridWriteStream = Grid.current.createWriteStream({ _id: mongoose.Types.ObjectId(), mode: "w" });
Error:
node_modules/mongoose/node_modules/mongodb/lib/mongodb/gridfs/gridstore.js:1564 } else if(self.safe.w != null || typeof self.safe.j == 'boolean' || typeof s ^ TypeError: Cannot read property 'w' of undefined
Versions: "mongoose": "~3.8.20" "gridfs-stream": "0.5.3"