Class: ROM::Mongo::Dataset
- Inherits:
-
Object
- Object
- ROM::Mongo::Dataset
- Defined in:
- lib/rom/mongo/dataset.rb
Defined Under Namespace
Classes: Criteria
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#criteria ⇒ Object
readonly
Returns the value of attribute criteria.
Instance Method Summary collapse
- #each ⇒ Object private
- #find(criteria = {}) ⇒ Object
-
#initialize(collection, criteria = Criteria.new) ⇒ Dataset
constructor
A new instance of Dataset.
- #insert(data) ⇒ Object
- #limit(limit) ⇒ Object
- #only(fields) ⇒ Object
- #order(value) ⇒ Object
- #remove_all ⇒ Object
- #skip(value) ⇒ Object
- #to_a ⇒ Object
- #update_all(attributes) ⇒ Object
- #where(doc) ⇒ Object
- #without(fields) ⇒ Object
Constructor Details
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
15 16 17 |
# File 'lib/rom/mongo/dataset.rb', line 15 def collection @collection end |
#criteria ⇒ Object (readonly)
Returns the value of attribute criteria.
17 18 19 |
# File 'lib/rom/mongo/dataset.rb', line 17 def criteria @criteria end |
Instance Method Details
#each ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/rom/mongo/dataset.rb', line 28 def each view.each { |doc| yield(doc) } end |
#find(criteria = {}) ⇒ Object
19 20 21 |
# File 'lib/rom/mongo/dataset.rb', line 19 def find(criteria = {}) Dataset.new(collection, Criteria.new.where(criteria)) end |
#insert(data) ⇒ Object
32 33 34 |
# File 'lib/rom/mongo/dataset.rb', line 32 def insert(data) collection.insert_one(data) end |
#limit(limit) ⇒ Object
56 57 58 |
# File 'lib/rom/mongo/dataset.rb', line 56 def limit(limit) dataset(criteria.limit(limit)) end |
#only(fields) ⇒ Object
48 49 50 |
# File 'lib/rom/mongo/dataset.rb', line 48 def only(fields) dataset(criteria.only(fields)) end |
#order(value) ⇒ Object
64 65 66 |
# File 'lib/rom/mongo/dataset.rb', line 64 def order(value) dataset(criteria.order(value)) end |
#remove_all ⇒ Object
40 41 42 |
# File 'lib/rom/mongo/dataset.rb', line 40 def remove_all view.delete_many end |
#skip(value) ⇒ Object
60 61 62 |
# File 'lib/rom/mongo/dataset.rb', line 60 def skip(value) dataset(criteria.skip(value)) end |
#to_a ⇒ Object
23 24 25 |
# File 'lib/rom/mongo/dataset.rb', line 23 def to_a view.to_a end |
#update_all(attributes) ⇒ Object
36 37 38 |
# File 'lib/rom/mongo/dataset.rb', line 36 def update_all(attributes) view.update_many(attributes) end |
#where(doc) ⇒ Object
44 45 46 |
# File 'lib/rom/mongo/dataset.rb', line 44 def where(doc) dataset(criteria.where(doc)) end |
#without(fields) ⇒ Object
52 53 54 |
# File 'lib/rom/mongo/dataset.rb', line 52 def without(fields) dataset(criteria.without(fields)) end |