Method: MongoDoc::Contexts::Mongo#execute
- Defined in:
- lib/mongo_doc/contexts/mongo.rb
#execute(paginating = false) ⇒ Object
Execute the context. This will take the selector and options and pass them on to the Ruby driver’s find() method on the collection. The collection itself will be retrieved from the class provided, and once the query has returned new documents of the type of class provided will be instantiated.
Example:
mongo.execute
Returns:
An enumerable Cursor.
94 95 96 97 98 99 100 101 102 |
# File 'lib/mongo_doc/contexts/mongo.rb', line 94 def execute(paginating = false) cursor = collection.find(selector, ) if cursor @count = cursor.count if paginating cursor else [] end end |