Module: IseshimaStore::QueryMethods

Included in:
Relation
Defined in:
lib/iseshima_store/query_methods.rb

Instance Method Summary collapse

Instance Method Details

#allObject



12
13
14
# File 'lib/iseshima_store/query_methods.rb', line 12

def all
  to_a
end

#inspectObject



27
28
29
# File 'lib/iseshima_store/query_methods.rb', line 27

def inspect
  to_a.inspect
end

#to_aObject



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