christkv/node-mongodb-native — Issue #531: Cannot save files with the same file name to GridFS.
Author: ryancole
Created: 2012-03-06 17:59:21+00:00
State: open

After trying to use this lib, and then looking over the code, it does not look like it's possible to save a file to GridFS that has a file name matching a previously saved file. It looks like the `GridStore#open` method will open the previous file entry, if it locates the file name, even even erase the contents if you've specified `w` mode!

I was going to switch from node-mongolian back to node-mongodb-native, because node-mongolian does the same.

Why is it that both node.js drivers are treating GridFS as an operating system file system rather than a database for files with a unique constraint on file name? MongoDB's documentation for GridFS does not say that `filename` is to be unique and it would seem to imply that it's not to be unique by saying that it is an optional field. That's my take on it, anyways. Also, the `mongofiles` tool that ships with MongoDB allows duplicate file names.

At first, I thought it may just be the `Grid` helper Object that was assuming I wanted to update an existing file, but it appears to be logic deeper inside the `GridStore` itself.

Is it possible to write files to GridFS using the same file name with the node-mongodb-native lib?