Class: CouchClient::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/couch-client/database.rb

Overview

Database is just an organized collection of functions that interact with the CouchDB database such as stats, creation, compaction, replication and deletion.

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Database

Database is constructed with a connection that is used to make HTTP requests to the server.



6
7
8
# File 'lib/couch-client/database.rb', line 6

def initialize(connection)
  @connection = connection
end

Instance Method Details

#compact!Object



26
27
28
# File 'lib/couch-client/database.rb', line 26

def compact!
  @connection.hookup.post(["_compact"]).last
end

#createObject



18
19
20
# File 'lib/couch-client/database.rb', line 18

def create
  @connection.hookup.put.last
end

#delete!Object



22
23
24
# File 'lib/couch-client/database.rb', line 22

def delete!
  @connection.hookup.delete.last
end

#exists?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/couch-client/database.rb', line 14

def exists?
  @connection.hookup.get.first == 200
end

#inspectObject



35
36
37
# File 'lib/couch-client/database.rb', line 35

def inspect
  "#<#{self.class}>"
end

#replicateObject

TODO: add replicate method



31
32
33
# File 'lib/couch-client/database.rb', line 31

def replicate
  raise "pending"
end

#statsObject



10
11
12
# File 'lib/couch-client/database.rb', line 10

def stats
  @connection.hookup.get.last
end