aheckmann / gridfs-stream

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

Add findOne function and fix Grid.collection not reflecting name #64

Closed healiha closed 9 years ago

healiha commented 9 years ago

This is an implementation of the feature proposed here https://github.com/aheckmann/gridfs-stream/issues/62 and a fix for https://github.com/aheckmann/gridfs-stream/issues/59

Prototype: findOne(options, callback)

findOne can be used like mongodb's findOne:

var gfs = Grid(db);

gfs.findOne({ _id: '54dd3fd6f9a55f1c1b25664d' }, function(err, res) {
  // res contains file or null if it did not match any file in the current collection
});

Optionally, it's possible to set options.root to specify which collection will the findOne execute on.

Reggino commented 9 years ago

Looks good. I've merged it, updated README.md and the test and released this as version 1.0.1

Thank you!

healiha commented 9 years ago

You're welcome!

julb commented 9 years ago

Thanks @healiha ! (for fixing #62)