Skip to content

Instantly share code, notes, and snippets.

@andresf
Created August 27, 2012 17:58
Show Gist options
  • Save andresf/3490864 to your computer and use it in GitHub Desktop.
Save andresf/3490864 to your computer and use it in GitHub Desktop.
Skipping mongoid instantiation
For Mongoid 2.4.x:
collection = Mongoid.master.collections("libraries")
collection.find({ user_id: current_user.id }, fields: { documents: 1 }).entries.to_json
For Mongoid 3.x:
Library.collection.find({ user_id: current_user.id }).select(documents: 1).to_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment