I'm using Gridfs to store files and allow the possibility of storing the same file but incrementing a version variable in the file's metadata. I'm using gridfs-stream to access the collection. So I'm trying to get the latest version out of the collection and I know I can use:
{sort: [['uploadDate', 'desc']]}
but I'd like to sort by the metadata version field that is named '__v'. I'm guessing the format to do that is this:
gfs.collection().findOne({'metadata.fd': fd}, {sort: [['metadata.__v', 'desc']]}, function(err, file) {}