Class: Sputnik::Index
Class Method Summary collapse
- .all(database_name, collection_name) ⇒ Object
- .create(database_name, collection_name, params) ⇒ Object
- .delete(database_name, collection_name, index_name) ⇒ Object
- .find(database_name, collection_name, index_name) ⇒ Object
Instance Method Summary collapse
- #all(params = nil) ⇒ Object
- #create(params = nil) ⇒ Object
- #delete(name = nil) ⇒ Object
- #find(name = nil, params = nil) ⇒ Object
Methods inherited from Base
Class Method Details
.all(database_name, collection_name) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/sputnik/index.rb', line 4 def all(database_name, collection_name) response = client.get("/databases/#{database_name}/collections/#{collection_name}/indexes") values = [] response.each do |item| values << Index.new(item) end values end |
.create(database_name, collection_name, params) ⇒ Object
17 18 19 |
# File 'lib/sputnik/index.rb', line 17 def create(database_name, collection_name, params) Index.new(client.post("/databases/#{database_name}/collections/#{collection_name}/indexes", params)) end |
.delete(database_name, collection_name, index_name) ⇒ Object
21 22 23 |
# File 'lib/sputnik/index.rb', line 21 def delete(database_name, collection_name, index_name) client.delete("/databases/#{database_name}/collections/#{collection_name}/indexes/#{index_name}") end |
.find(database_name, collection_name, index_name) ⇒ Object
13 14 15 |
# File 'lib/sputnik/index.rb', line 13 def find(database_name, collection_name, index_name) Index.new(client.get("/databases/#{database_name}/collections/#{collection_name}/indexes/#{index_name}")) end |
Instance Method Details
#all(params = nil) ⇒ Object
26 27 28 |
# File 'lib/sputnik/index.rb', line 26 def all(params=nil) Index.all(collection.database.db, collection.name, params || self.to_hash) end |
#create(params = nil) ⇒ Object
34 35 36 |
# File 'lib/sputnik/index.rb', line 34 def create(params=nil) Index.create(collection.database.db, collection.name, params || self.to_hash) end |