aheckmann / gridfs-stream

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

Get File information by passing _id as String #62

Closed julb closed 9 years ago

julb commented 9 years ago

Hi,

It can be useful to get the information of a file using its _id.

I did this in my method:

gfs.files.find({ _id: gfs.tryParseObjectId('54da7b013706c1e7ab25f9fa') }).toArray(function (err, files) { console.log(files[0]); });

It would be easier to write it like this: gfs.findOne({ _id: '54da7b013706c1e7ab25f9fa'}, function (err, file) { console.log(file); });

What do you think of this ?

Reggino commented 9 years ago

This is added in v1.0.1 by @healiha

Thanks for the suggestion!