Module: CartoDB::Model::Query::ClassMethods
- Defined in:
- lib/cartodb-rb-client/cartodb/model/query.rb
Instance Method Summary collapse
- #all ⇒ Object
- #count ⇒ Object
- #find(id) ⇒ Object
- #order(order_clause) ⇒ Object
- #page(page_number) ⇒ Object
- #per_page(ammount) ⇒ Object
- #select(*fields) ⇒ Object
- #where(attributes = nil, *rest) ⇒ Object
Instance Method Details
#all ⇒ Object
16 17 18 19 |
# File 'lib/cartodb-rb-client/cartodb/model/query.rb', line 16 def all scope = Scope.new(self) scope.all end |
#count ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/cartodb-rb-client/cartodb/model/query.rb', line 30 def count begin results = connection.query "SELECT COUNT(CARTODB_ID) FROM #{table_name}" results.rows.first[:count].try(:to_i) rescue Exception => e 0 end end |
#find(id) ⇒ Object
26 27 28 |
# File 'lib/cartodb-rb-client/cartodb/model/query.rb', line 26 def find(id) where(id) end |
#order(order_clause) ⇒ Object
49 50 51 52 |
# File 'lib/cartodb-rb-client/cartodb/model/query.rb', line 49 def order(order_clause) scope = Scope.new(self) scope.order(order_clause) end |
#page(page_number) ⇒ Object
39 40 41 42 |
# File 'lib/cartodb-rb-client/cartodb/model/query.rb', line 39 def page(page_number) scope = Scope.new(self) scope.page(page_number) end |
#per_page(ammount) ⇒ Object
44 45 46 47 |
# File 'lib/cartodb-rb-client/cartodb/model/query.rb', line 44 def per_page(ammount) scope = Scope.new(self) scope.page(page_number) end |