aheckmann / gridfs-stream

Easily stream files to and from MongoDB
MIT License
615 stars 120 forks source link

Support for arbitrary "_id" types #40

Closed llmora closed 10 years ago

llmora commented 10 years ago

The "_id" of a file in the GridFS can be of any type (not just ObjectID), see:

http://mongodb.github.io/node-mongodb-native/api-generated/gridstore.html

Our application uses custom "_id" types and we noticed that gridfs-stream did not work as expected, tracked it down to a hard-coded support for ObjectIDs as the only supported type for "_id".

This simple pull request adds support for any type of object as the "_id", however to mantain backward compatibility strings of 12 or 24 characters are considered ObjectID identifiers and treated as such.

Added a couple of unit tests to test the new functionality.

Reggino commented 10 years ago

lgtm thanks