Class: MongoAccessor
- Inherits:
-
Object
- Object
- MongoAccessor
- Defined in:
- lib/mongo/mongo.rb
Instance Method Summary collapse
- #get_documents(limit) ⇒ Object
- #get_documents_by_ts(date, limit) ⇒ Object
-
#initialize(url, collection, client_host) ⇒ MongoAccessor
constructor
A new instance of MongoAccessor.
Constructor Details
#initialize(url, collection, client_host) ⇒ MongoAccessor
Returns a new instance of MongoAccessor.
5 6 7 8 9 10 11 |
# File 'lib/mongo/mongo.rb', line 5 def initialize(url, collection, client_host) connection = Mongo::Client.new(url) @mongodb = connection.database @collection = @mongodb.collection(collection) @client_host = client_host end |
Instance Method Details
#get_documents(limit) ⇒ Object
17 18 19 |
# File 'lib/mongo/mongo.rb', line 17 def get_documents(limit) @collection.find({:client => {:$ne => @client_host}}).limit(limit) end |
#get_documents_by_ts(date, limit) ⇒ Object
13 14 15 |
# File 'lib/mongo/mongo.rb', line 13 def get_documents_by_ts(date, limit) @collection.find({:ts => {:$gt => date}, :client => {:$ne => @client_host}}).limit(limit) end |