Class: MongoHQClient::Collection
- Inherits:
-
Object
- Object
- MongoHQClient::Collection
show all
- Includes:
- Commons, HTTP
- Defined in:
- lib/mongohq-client/collection.rb
Instance Method Summary
collapse
Methods included from HTTP
#delete, #get, #post
Methods included from Commons
#initialize, #method_missing
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class MongoHQClient::Commons
Instance Method Details
#document(id) ⇒ Object
18
19
20
21
22
|
# File 'lib/mongohq-client/collection.rb', line 18
def document(id)
json = get("databases/#{database}/collections/#{name}/documents/#{id}")
Document.new(json: json)
end
|
#documents ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/mongohq-client/collection.rb', line 6
def documents
json = get("databases/#{database}/collections/#{name}/documents")
documents = []
json.each do |doc|
documents << Document.new(json:doc)
end
documents
end
|
#indexes ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/mongohq-client/collection.rb', line 24
def indexes
json = get("databases/#{database}/collections/#{name}/indexes")
indexes = []
json.each do |index|
indexes << Index.new(json: index)
end
indexes
end
|