Class: Sputnik::Index

Inherits:
Base
  • Object
show all
Defined in:
lib/sputnik/index.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

client

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

#delete(name = nil) ⇒ Object



38
39
40
# File 'lib/sputnik/index.rb', line 38

def delete(name=nil)
  Index.delete(collection.database.db, collection.name, name || self.name)
end

#find(name = nil, params = nil) ⇒ Object



30
31
32
# File 'lib/sputnik/index.rb', line 30

def find(name=nil, params=nil)
  Index.find(collection.database.db, collection.name, name || self.name, params || self.to_hash)
end