Module: CassandraObject::Scope::FinderMethods

Included in:
CassandraObject::Scope
Defined in:
lib/cassandra_object/scope/finder_methods.rb

Instance Method Summary collapse

Instance Method Details

#find(ids) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/cassandra_object/scope/finder_methods.rb', line 4

def find(ids)
  if ids.is_a?(Array)
    find_some(ids)
  else
    find_one(ids)
  end
end

#find_all_in_batches(next_cursor = nil) ⇒ Object



25
26
27
28
29
30
# File 'lib/cassandra_object/scope/finder_methods.rb', line 25

def find_all_in_batches(next_cursor = nil)
  obj = self.clone
  obj.is_all = true
  obj.next_cursor = next_cursor
  obj.execute
end

#find_by_id(ids) ⇒ Object



12
13
14
15
16
# File 'lib/cassandra_object/scope/finder_methods.rb', line 12

def find_by_id(ids)
  find(ids)
rescue CassandraObject::RecordNotFound
  nil
end

#find_in_batches(id, next_cursor = nil) ⇒ Object



18
19
20
21
22
23
# File 'lib/cassandra_object/scope/finder_methods.rb', line 18

def find_in_batches(id, next_cursor = nil)
  obj = self.clone
  obj.is_all = true
  obj.next_cursor = next_cursor
  obj.where_ids(id).execute_paged
end

#firstObject



32
33
34
35
# File 'lib/cassandra_object/scope/finder_methods.rb', line 32

def first
  return limit(1).find_all_in_batches[:results].first if self.schema_type == :dynamic_attributes || self.schema_type == :schemaless
  limit(1).execute.first
end