Documentation
¶
Overview ¶
Package couch provides a CouchDB API.
Index ¶
- Variables
- type ChangeHandler
- type DBInfo
- type Database
- func (p Database) BaseURL() string
- func (p Database) Bulk(docs []interface{}) ([]Response, error)
- func (p Database) Changes(handler ChangeHandler, options map[string]interface{}) error
- func (p Database) DBURL() string
- func (p Database) Delete(id, rev string) error
- func (p Database) DeleteDatabase() error
- func (p Database) Edit(d interface{}) (string, error)
- func (p Database) EditWith(d interface{}, id, rev string) (string, error)
- func (p Database) Exists() bool
- func (p Database) GetInfo() (DBInfo, error)
- func (p Database) Insert(d interface{}) (string, string, error)
- func (p Database) InsertWith(d interface{}, id string) (string, string, error)
- func (p Database) Query(view string, options map[string]interface{}, results interface{}) error
- func (p Database) QueryIds(view string, options map[string]interface{}) ([]string, error)
- func (p Database) Retrieve(id string, d interface{}) error
- func (p Database) Running() bool
- func (p Database) ViewURL(view string, params map[string]interface{}) (string, error)
- type DocID
- type Response
- type Row
Constants ¶
This section is empty.
Variables ¶
var HTTPClient = http.DefaultClient
HTTP Client used by typical requests.
Defaults to http.DefaultClient
Functions ¶
This section is empty.
Types ¶
type ChangeHandler ¶
A ChangeHandler handles the stream of changes coming from Changes.
The handler returns the next sequence number when the stream should be resumed, otherwise -1 to indicate the changes feed should stop.
The handler may return at any time to restart the stream from the sequence number in indicated in its return value.
type DBInfo ¶
type DBInfo struct { Name string `json:"db_name"` DocCount int64 `json:"doc_count"` DocDelCount int64 `json:"doc_del_count"` UpdateSeq int64 `json:"update_seq"` PurgeSeq int64 `json:"purge_seq"` Compacting bool `json:"compact_running"` DiskSize int64 `json:"disk_size"` DataSize int64 `json:"data_size"` StartTime string `json:"instance_start_time"` Version int `json:"disk_format_version"` CommitedSeq int64 `json:"committed_update_seq"` }
DBInfo represents the result from GetInfo
type Database ¶
type Database struct { Host string Port string Name string // contains filtered or unexported fields }
Database represents operations available on an existing CouchDB
func Connect ¶
Connect to the database at the given URL. example: couch.Connect("http://localhost:5984/testdb/")
func NewDatabase ¶
NewDatabase connects to a CouchDB server and creates the specified database if it does not exist.
func (Database) Bulk ¶
Bulk modification interface. Each item should be JSON serializable into a valid document. "_id" and "_rev" will be honored. To delete, add a "_deleted" field with a value of "true" as well as a valid "_rev" field.
func (Database) Changes ¶
func (p Database) Changes(handler ChangeHandler, options map[string]interface{}) error
Changes feeds a ChangeHandler a CouchDB changes feed.
The handler receives the body of the stream and is expected to consume the contents.
func (Database) DeleteDatabase ¶
DeleteDatabase deletes the given database and all documents
func (Database) Edit ¶
Edit edits the given document, returning the new revision. d must contain "_id" and "_rev" tagged fields.
func (Database) EditWith ¶
EditWith edits the given document, returning the new revision. d should not contain "_id" or "_rev" tagged fields. If it does, they will be overwritten with the passed values.
func (Database) Insert ¶
Insert a document into CouchDB, returning id and rev on success. Document may specify both "_id" and "_rev" fields (will overwrite existing)
or just "_id" (will use that id, but not overwrite existing) or neither (will use autogenerated id)
func (Database) InsertWith ¶
InsertWith inserts the given document (shouldn't contain "_id" or "_rev" tagged fields) using the passed 'id' as the _id. Will fail if the id already exists.
func (Database) QueryIds ¶
QueryIds returns a slice of document ids as returned by the given view/options combo. view should be eg. "_design/my_foo/_view/my_bar" options should be eg. { "limit": 10, "key": "baz" }