christkv/node-mongodb-native — Issue #399: findOne() does not support all the options find() does
Author: jgonera
Created: 2011-11-09 15:13:45+00:00
State: open

This works as expected:

collection('posts', function(err, collection) {
collection.find({_id: someid}, {comments: {$slice: -5}).toArray(function(err, docs) {
// docs[0] contains the post with its last 5 comments
});
});

And this doesn't:

collection('posts', function(err, collection) {
collection.findOne({_id: someid}, {comments: {$slice: -5}, function(err, doc) {
// doc contains the post with all its comments
// {comments: {$slice: -5}} silently ignored
});
});