Class: DataStore

Inherits:
Object show all
Defined in:
app/volt/tasks/live_query/data_store.rb

Instance Method Summary collapse

Constructor Details

#initializeDataStore

Returns a new instance of DataStore.



4
5
# File 'app/volt/tasks/live_query/data_store.rb', line 4

def initialize
end

Instance Method Details

#dbObject



7
8
9
# File 'app/volt/tasks/live_query/data_store.rb', line 7

def db
  @@db ||= Volt::DataStore.fetch
end

#query(collection, query) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'app/volt/tasks/live_query/data_store.rb', line 11

def query(collection, query)
  # Extract query parts
  query, skip, limit = query

  cursor = db[collection].find(query)
  cursor = cursor.skip(skip) if skip
  cursor = cursor.limit(limit) if limit

  return cursor.to_a
end