Module: IseshimaStore::QueryMethods
- Included in:
- Relation
- Defined in:
- lib/iseshima_store/query_methods.rb
Instance Method Summary collapse
- #all ⇒ Object
- #inspect ⇒ Object
- #to_a ⇒ Object
- #where(condition) ⇒ Object
- #where!(condition) ⇒ Object
Instance Method Details
#all ⇒ Object
12 13 14 |
# File 'lib/iseshima_store/query_methods.rb', line 12 def all to_a end |
#inspect ⇒ Object
27 28 29 |
# File 'lib/iseshima_store/query_methods.rb', line 27 def inspect to_a.inspect end |
#to_a ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/iseshima_store/query_methods.rb', line 16 def to_a query = Gcloud::Datastore::Query.new query.kind(@klass.to_s) @where_clause.conditions.each do |condition| query.where(*condition) end results = IseshimaStore::Connection.current.run(query) results.map { |entity| @klass.from_entity(entity) } end |
#where(condition) ⇒ Object
3 4 5 |
# File 'lib/iseshima_store/query_methods.rb', line 3 def where(condition) spawn.where!(condition) end |
#where!(condition) ⇒ Object
7 8 9 10 |
# File 'lib/iseshima_store/query_methods.rb', line 7 def where!(condition) @where_clause += condition self end |