Module: CartoDB::Model::Query::ClassMethods

Defined in:
lib/cartodb-rb-client/cartodb/model/query.rb

Instance Method Summary collapse

Instance Method Details

#allObject



16
17
18
19
# File 'lib/cartodb-rb-client/cartodb/model/query.rb', line 16

def all
  scope = Scope.new(self)
  scope.all
end

#countObject



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

#select(*fields) ⇒ Object



11
12
13
14
# File 'lib/cartodb-rb-client/cartodb/model/query.rb', line 11

def select(*fields)
  scope = Scope.new(self)
  scope.select(fields)
end

#where(attributes = nil, *rest) ⇒ Object



21
22
23
24
# File 'lib/cartodb-rb-client/cartodb/model/query.rb', line 21

def where(attributes = nil, *rest)
  scope = Scope.new(self)
  scope.where(attributes, rest)
end