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
# File 'lib/daodalus/dsl/queries.rb', line 5

def find(options = {})
  dao.find(query.wheres).select(query.selects)
end

#find_oneObject



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

def find_one
  Option[dao.find(query.wheres).select(query.selects).one]
end

#remove(options = {}) ⇒ Object



13
14
15
# File 'lib/daodalus/dsl/queries.rb', line 13

def remove(options = {})
  dao.find(query.wheres).remove_all
end

#select(*fields) ⇒ Object



25
26
27
# File 'lib/daodalus/dsl/queries.rb', line 25

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

#where(field = nil) ⇒ Object



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

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