Regarding the GridStore constructor:
When null is supplied as ObjectId and an extra filename is passed, the GridStore will not try to query by filename.
This patch fixes this.
are you trying to save a file using a filename then you just do
new GridStore(db, "filename", "w")
new GridStore(db, null, "filename", "w")
I got that now, but that wasn't obvious for me by looking at the code and/or the method signature: I thought passing an explicit null-value for the objectId would trigger a filename-based lookup. And besides: the typos in the code make it even more 'unclear'.
yeah it's the hubris of legacy code. the second option is for setting a filename as metadata not as the id itself. The best options is usually to pass in a id and a filename.
The reason i came with this issue is this issue in gridfs-stream:
A 12-lettered (or 24 lettered) string/filename COULD internally be casted to an ObjectId (but this is not the case for GridStore). To prevent this possible mixup, i think it is a good idea to make it a bit more explicit whether a 'filename' or 'ObjectId' is passed
yeah I know but I can't break backward compatibility and this pull request would as it would mange the last options object as you pointed out by modifying a test to make it pass.
That test was broken before i changed anything ;-) I think the change IS backwards compatible!
(i should not have added the test-change in the same pull request, sry)
passes here an on travis without the changes so I'm not sure why it does not pass on you system
Support for ObjectId = null as parameter
Reverted the (unrelated) test change
Typo: indexOf() never returns null
Closing as not going to support