gridfs-stream
gridfs-stream copied to clipboard
Updating file information via gridfs.files.update()
I am trying to update the filename and metadata via gridfs.files (as suggested by #98):
gridfs.files.update(
{ _id: req.params.id },
{ $set: { filename: req.body.filename } },
(err, updated) => { ... }
)
However, this is not working for me on gridfs-stream 1.1.1 and mongod 3.2.11:
{ ok: 1,
nModified: 0,
n: 0,
opTime: { ts: [Object], t: 1 },
electionId: 7fffffff0000000000000001 }
Any idea what could be wrong? Did this feature break in a later version of this library/mongod?
I noticed that it is picky about ObjectIds. So it must be probably if you use mongoose:
ObjectId = require('mongoose').Types.ObjectId
...
_id: new ObjectId(req.params.id)
To debug, try first to find the file with your filter and then to update it.