Skip to content
Browse files

Support field selection in server-side mongo.

Can now publish subsets of documents with something like this:

Meteor.publish('items', function (sub, params) {
  return Items.find({user_id: params.user_id},
                    {fields: {some_secret_field: 0}});
});

where items.some_secret_fields won't be included in the publish output.

(fields option is ignored by minimongo.)
  • Loading branch information...
1 parent fa53aa6 commit 6f676a9a3b029d5c2f85884fdc577e994d2cf1bf @debergalis debergalis committed Feb 25, 2012
Showing with 1 addition and 11 deletions.
  1. +1 −11 packages/mongo-livedata/mongo_driver.js
View
12 packages/mongo-livedata/mongo_driver.js
@@ -194,16 +194,7 @@ _Mongo.Cursor = function (mongo, collection_name, selector, options) {
self.mongo._withCollection(collection_name, function(err, collection) {
// XXX err handling
-
- var cursor = collection.find(self.selector);
- // XXX is there a way to do this as for x in ['sort', 'limit', 'skip']?
- if (self.options.sort)
- cursor = cursor.sort(self.options.sort);
- if (self.options.limit)
- cursor = cursor.limit(self.options.limit);
- if (self.options.skip)
- cursor = cursor.skip(self.options.skip);
-
+ var cursor = collection.find(self.selector, self.options.fields, self.options.skip, self.options.limit, self.options.sort);
future.ret(cursor);
});
@@ -267,7 +258,6 @@ _Mongo.Cursor.prototype.count = function () {
// - changed (new_object, at_index)
// - moved (object, old_index, new_index) - can only fire with changed()
// - removed (id, at_index)
-// * sort: sort descriptor
//
// attributes available on returned LiveResultsSet
// * stop(): end updates

0 comments on commit 6f676a9

Please sign in to comment.
Something went wrong with that request. Please try again.