Module: Daodalus::DSL::Queries

Included in:
Daodalus::DSL, Select, Update, Where
Defined in:
lib/daodalus/dsl/queries.rb

Instance Method Summary collapse

Instance Method Details

#find(options = {}) ⇒ Object



5
6
7
8
# File 'lib/daodalus/dsl/queries.rb', line 5

def find(options = {})
  options = options.merge(fields: query.selects) if query.has_selects?
  dao.find(query.wheres, options)
end

#find_one(options = {}) ⇒ Object



10
11
12
13
# File 'lib/daodalus/dsl/queries.rb', line 10

def find_one(options = {})
  options = options.merge(fields: query.selects) if query.has_selects?
  dao.find_one(query.wheres, options)
end

#select(*fields) ⇒ Object



23
24
25
# File 'lib/daodalus/dsl/queries.rb', line 23

def select *fields
  Select.new(dao, query, fields)
end

#where(field = nil) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/daodalus/dsl/queries.rb', line 15

def where field=nil
  if field.is_a? Hash
    Where.new(dao, query.where(field), nil)
  else
    Where.new(dao, query, field)
  end
end