taken from mongodb documentation at: http://docs.mongodb.org/manual/reference/method/db.collection.find/
Exclude certain fields from the result set. In the following example, documents that match the selection criteria are selected and excludes the set of fields from the resulting documents:
db.products.find( { qty: { $gt: 25 } }, { _id: 0, qty: 0 } ) query returns all documents from the collection products, where qty is greater than 25. Documents in the result set will contain all fields except the _id and qty fields, as shown below:
{ "item" : "pencil", "type" : "no.2" } { "item" : "bottle", "type" : "blue" } { "item" : "paper" }
Suppose mongoid sets the _id attribute to nil, since mongoid models have a specific set of attributes (even if they are dynamic, _id, _type, etc.). perhaps you can try it with the mongodb driver.
but I think RedXVII's answer is a more practical way to go
source share