README

Build Status Codecov GoDoc

Kivik

Package kivik provides a generic interface to CouchDB or CouchDB-like databases.

The kivik package must be used in conjunction with a database driver.

The kivik driver system is modeled after the standard library's sql and sql/driver packages, although the client API is completely different due to the different database models implemented by SQL and NoSQL databases such as CouchDB.

Installation

Install Kivik as you normally would for any Go package:

go get -u github.com/flimzy/kivik

This will install the main Kivik package, as well as the CouchDB and PouchDB drivers. See the list of Kivik database drivers for a complete list of available drivers.

Example Usage

Please consult the the package documentation for all available API methods, and a complete usage documentation. And for additional usage examples, consult the wiki.

package main

import (
    "fmt"

    "github.com/flimzy/kivik"
    _ "github.com/flimzy/kivik/driver/couchdb" // The CouchDB driver
)

func main() {
    client, err := kivik.New(context.TODO(), "couch", "http://localhost:5984/")
    if err != nil {
        panic(err)
    }

    db, err := client.DB(context.TODO(), "animals")
    if err != nil {
        panic(err)
    }

    doc := map[string]interface{}{
        "_id":      "cow",
        "feet":     4,
        "greeting": "moo",
    }

    rev, err := db.Put(context.TODO(), "cow", doc)
    if err != nil {
        panic(err)
    }
    fmt.Printf("Cow inserted with revision %s\n", rev)
}

Frequently Asked Questions

Nobody has ever asked me any of these questions, so they're probably better called "Never Asked Questions" or possibly "Imagined Questions."

Why another CouchDB client API?

Read the design goals for the general design goals.

Specifically, I was motivated to write Kivik for a few reasons:

  1. I was unhappy with any of the existing CouchDB drivers for Go. The best one had a number of shortcomings:

    • It is no longer actively developed.
    • It doesn't have an open source license.
    • It doesn't support iterating over result sets, forcing one to load all results of a query into memory at once.
    • It doesn't support CouchDB 2.0 sequence IDs or MongoDB-style queries.
    • It doesn't natively support CookieAuth (it does allow a generic Auth method which could be used to do this, but I think it's appropriate to put directly in the library).
  2. I wanted a single client API that worked with both CouchDB and PouchDB. I had previously written go-pouchdb, a GopherJS wrapper around the PouchDB library with a public API modeled after fjl/go-couchdb, but I still wanted a unified driver infrastructure.

  3. I want an unambiguous, open source license. This software is released under the Apache 2.0 license. See the included LICENSE.md file for details.

  4. I wanted the ability to mock CouchDB connections for testing. This is possible with the sql / sql/driver approach by implementing a mock driver, but was not possible with any existing CouchDB client libraries. This library makes that possible for CouchDB apps, too.

  5. I wanted a simple, mock CouchDB server I could use for testing. It doesn't need to be efficient, or support all CouchDB servers, but it should be enough to test the basic functionality of a PouchDB app, for instance. Kivik aims to do this with the kivik serve command, in the near future.

  6. I wanted a toolkit that would make it easy to build a proxy to sit in front of CouchDB to handle custom authentication or other logic that CouchDB cannot support natively. Kivik aims to accomplish this in the future.

What is the development status?

Kivik comes with a complete client API client and backend drivers for CouchDB and PouchDB.

My next priorities are to work on fleshing out the Memory driver, which will make automated testing without a real CouchDB server easier. Then I will work on completing the 'serve' mode.

You can see a complete overview of the current status on the Compatibility chart

Why the name "Kivik"?

Kivik is a line of sofas (couches) from IKEA. And in the spirit of IKEA, and build-your-own furniture, Kivik aims to allow you to "build your own" CouchDB client, server, and proxy applications.

What license is Kivik released under?

This software is released under the terms of the Apache 2.0 license. See LICENCE.md, or read the full license.

Expand ▾ Collapse ▴

Documentation

Overview

Package kivik provides a generic interface to CouchDB or CouchDB-like databases.

The kivik package must be used in conjunction with a database driver. See https://github.com/flimzy/kivik/wiki/Kivik-database-drivers for a list.

The kivik driver system is modeled after the standard library's sql and sql/driver packages, although the client API is completely different due to the different database models implemented by SQL and NoSQL databases such as CouchDB.

Contexts in Kivik

Most functions that may block require a Context as their first argument. The context permits cancelling a blocked function in case of a timeout, or some other event (such as a cancelled HTTP request if a web server). Be sure to read the context package GoDocs at https://golang.org/pkg/context/ and see https://blog.golang.org/context for example code for a server that uses Contexts.

If in doubt, you can pass context.TODO() as the context variable. Think of the TODO context as a place-holder for cases when it is unclear which Context to use, or when surrounding functions have not yet been extended to support a Context parameter.

For example:

client, err := kivik.New(context.TODO(), "couch", "http://localhost:5984/")

Index

Constants

View Source
const (
	MethodGet    = "GET"
	MethodHead   = "HEAD"
	MethodPost   = "POST"
	MethodPut    = "PUT"
	MethodDelete = "DELETE"
	MethodCopy   = "COPY"
)

    HTTP methods supported by CouchDB. This is almost an exact copy of the methods in the standard http package, with the addition of MethodCopy, and a few methods left out which are not used by CouchDB.

    View Source
    const (
    	StatusOK                           = 200
    	StatusCreated                      = 201
    	StatusAccepted                     = 202
    	StatusFound                        = 302
    	StatusNotModified                  = 304
    	StatusBadRequest                   = 400
    	StatusUnauthorized                 = 401
    	StatusForbidden                    = 403
    	StatusNotFound                     = 404
    	StatusResourceNotAllowed           = 405
    	StatusRequestTimeout               = 408
    	StatusConflict                     = 409
    	StatusPreconditionFailed           = 412
    	StatusBadContentType               = 415
    	StatusRequestedRangeNotSatisfiable = 416
    	StatusExpectationFailed            = 417
    	StatusInternalServerError          = 500
    	// StatusNotImplemented is not returned by CouchDB proper. It is used by
    	// Kivik for optional features which are not implemented by some drivers.
    	StatusNotImplemented = 501
    )

      HTTP response codes permitted by the CouchDB API. See http://docs.couchdb.org/en/1.6.1/api/basics.html#http-status-codes

      View Source
      const SessionCookieName = "AuthSession"

        SessionCookieName is the name of the CouchDB session cookie.

        Variables

        This section is empty.

        Functions

        func Register

        func Register(name string, driver driver.Driver)

          Register makes a database driver available by the provided name. If Register is called twice with the same name or if driver is nil, it panics.

          func StatusCode

          func StatusCode(err error) int

            StatusCode returns the HTTP status code embedded in the error, or 500 (internal server error), if there was no specified status code. If err is nil, StatusCode returns 0. This provides a convenient way to determine the precise nature of a Kivik-returned error.

            For example, to panic for all but NotFound errors:

            row, err := db.Get(context.TODO(), "docID")
            if kivik.StatusCode(err) == kivik.StatusNotFound {
                return
            }
            if err != nil {
                panic(err)
            }
            

            This method uses the statusCoder interface, which is not exported by this package, but is considered part of the stable public API. Driver implementations are expected to return errors which conform to this interface.

            type statusCoder interface {
                StatusCode() int
            }
            

            Types

            type Attachment

            type Attachment struct {
            	io.ReadCloser
            	Filename    string
            	ContentType string
            	MD5         [16]byte
            }

              Attachment represents a file attachment on a CouchDB document.

              func NewAttachment

              func NewAttachment(filename, contentType string, body io.ReadCloser) *Attachment

                NewAttachment returns a new CouchDB attachment.

                func (*Attachment) Bytes

                func (a *Attachment) Bytes() ([]byte, error)

                  Bytes returns the attachment's body as a byte slice.

                  type BulkResults

                  type BulkResults struct {
                  	// contains filtered or unexported fields
                  }

                    BulkResults is an iterator over the results of a BulkDocs query.

                    func (*BulkResults) Close

                    func (r *BulkResults) Close() error

                      Close closes the feed. Any unread updates will still be accessible via Next().

                      func (*BulkResults) Err

                      func (r *BulkResults) Err() error

                        Err returns the error, if any, that was encountered during iteration. Err may be called after an explicit or implicit Close.

                        func (*BulkResults) ID

                        func (r *BulkResults) ID() string

                          ID returns the document ID name for the current result.

                          func (*BulkResults) Next

                          func (r *BulkResults) Next() bool

                            Next returns the next BulkResult from the feed. If an error occurs, it will be returned and the feed closed. io.EOF will be returned when there are no more results.

                            func (*BulkResults) Rev

                            func (r *BulkResults) Rev() string

                              Rev returns the revision of the current curResult.

                              func (*BulkResults) UpdateErr

                              func (r *BulkResults) UpdateErr() error

                                UpdateErr returns the error associated with the current result, or nil if none. Do not confuse this with Err, which returns an error for the iterator itself.

                                type Changes

                                type Changes struct {
                                	// contains filtered or unexported fields
                                }

                                  Changes is an iterator over the database changes feed.

                                  func (*Changes) Changes

                                  func (c *Changes) Changes() []string

                                    Changes returns a list of changed revs.

                                    func (*Changes) Close

                                    func (c *Changes) Close() error

                                      Close closes the Changes feed, preventing further enumeration, and freeing any resources (such as the http request body) of the underlying query. If Next is called and there are no further results, Changes is closed automatically and it will suffice to check the result of Err. Close is idempotent and does not affect the result of Err.

                                      func (*Changes) Deleted

                                      func (c *Changes) Deleted() bool

                                        Deleted returns true if the change relates to a deleted document.

                                        func (*Changes) Err

                                        func (c *Changes) Err() error

                                          Err returns the error, if any, that was encountered during iteration. Err may be called after an explicit or implicit Close.

                                          func (*Changes) ID

                                          func (c *Changes) ID() string

                                            ID returns the ID of the current result.

                                            func (*Changes) Next

                                            func (c *Changes) Next() bool

                                              Next prepares the next result value for reading. It returns true on success or false if there are no more results, due to an error or the changes feed having been closed. Err should be consulted to determine any error.

                                              func (*Changes) ScanDoc

                                              func (c *Changes) ScanDoc(dest interface{}) error

                                                ScanDoc works the same as ScanValue, but on the doc field of the result. It is only valid for results that include documents.

                                                type Client

                                                type Client struct {
                                                	// contains filtered or unexported fields
                                                }

                                                  Client is a client connection handle to a CouchDB-like server.

                                                  func New

                                                  func New(ctx context.Context, driverName, dataSourceName string) (*Client, error)

                                                    New creates a new client object specified by its database driver name and a driver-specific data source name.

                                                    func (*Client) AllDBs

                                                    func (c *Client) AllDBs(ctx context.Context, options ...Options) ([]string, error)

                                                      AllDBs returns a list of all databases.

                                                      func (*Client) Authenticate

                                                      func (c *Client) Authenticate(ctx context.Context, a interface{}) error

                                                        Authenticate authenticates the client with the passed authenticator, which is driver-specific. If the driver does not understand the authenticator, an error will be returned.

                                                        func (*Client) CreateDB

                                                        func (c *Client) CreateDB(ctx context.Context, dbName string, options ...Options) error

                                                          CreateDB creates a DB of the requested name.

                                                          func (*Client) DB

                                                          func (c *Client) DB(ctx context.Context, dbName string, options ...Options) (*DB, error)

                                                            DB returns a handle to the requested database. Any options parameters passed are merged, with later values taking precidence.

                                                            func (*Client) DBExists

                                                            func (c *Client) DBExists(ctx context.Context, dbName string, options ...Options) (bool, error)

                                                              DBExists returns true if the specified database exists.

                                                              func (*Client) DBUpdates

                                                              func (c *Client) DBUpdates() (*DBUpdates, error)

                                                                DBUpdates begins polling for database updates.

                                                                func (*Client) DSN

                                                                func (c *Client) DSN() string

                                                                  DSN returns the data source name used to connect this client.

                                                                  func (*Client) DestroyDB

                                                                  func (c *Client) DestroyDB(ctx context.Context, dbName string, options ...Options) error

                                                                    DestroyDB deletes the requested DB.

                                                                    func (*Client) Driver

                                                                    func (c *Client) Driver() string

                                                                      Driver returns the name of the driver string used to connect this client.

                                                                      func (*Client) GetReplications

                                                                      func (c *Client) GetReplications(ctx context.Context, options ...Options) ([]*Replication, error)

                                                                        GetReplications returns a list of defined replications in the _replicator database. Options are in the same format as to AllDocs(), except that "conflicts" and "update_seq" are ignored.

                                                                        func (*Client) Replicate

                                                                        func (c *Client) Replicate(ctx context.Context, targetDSN, sourceDSN string, options ...Options) (*Replication, error)

                                                                          Replicate initiates a replication from source to target.

                                                                          func (*Client) Version

                                                                          func (c *Client) Version(ctx context.Context) (*Version, error)

                                                                            Version returns version and vendor info about the backend.

                                                                            type DB

                                                                            type DB struct {
                                                                            	// contains filtered or unexported fields
                                                                            }

                                                                              DB is a handle to a specific database.

                                                                              func (*DB) AllDocs

                                                                              func (db *DB) AllDocs(ctx context.Context, options ...Options) (*Rows, error)

                                                                                AllDocs returns a list of all documents in the database.

                                                                                func (*DB) BulkDocs

                                                                                func (db *DB) BulkDocs(ctx context.Context, docs ...interface{}) (*BulkResults, error)

                                                                                  BulkDocs allows you to create and update multiple documents at the same time within a single request. This function returns an iterator over the results of the bulk operation. See http://docs.couchdb.org/en/2.0.0/api/database/bulk-api.html#db-bulk-docs

                                                                                  func (*DB) Changes

                                                                                  func (db *DB) Changes(ctx context.Context, options ...Options) (*Changes, error)

                                                                                    Changes returns an iterator over the real-time changes feed. The feed remains open until explicitly closed, or an error is encountered. See http://couchdb.readthedocs.io/en/latest/api/database/changes.html#get--db-_changes

                                                                                    func (*DB) Compact

                                                                                    func (db *DB) Compact(ctx context.Context) error

                                                                                      Compact begins compaction of the database. Check the CompactRunning field returned by Info() to see if the compaction has completed. See http://docs.couchdb.org/en/2.0.0/api/database/compact.html#db-compact

                                                                                      func (*DB) CompactView

                                                                                      func (db *DB) CompactView(ctx context.Context, ddocID string) error

                                                                                        CompactView compats the view indexes associated with the specified design document. See http://docs.couchdb.org/en/2.0.0/api/database/compact.html#db-compact-design-doc

                                                                                        func (*DB) Copy

                                                                                        func (db *DB) Copy(ctx context.Context, targetID, sourceID string, options ...Options) (targetRev string, err error)

                                                                                          Copy copies the source document to a new document with an ID of targetID. If the database backend does not support COPY directly, the operation will be emulated with a Get followed by Put. The target will be an exact copy of the source, with only the ID and revision changed.

                                                                                          See http://docs.couchdb.org/en/2.0.0/api/document/common.html#copy--db-docid

                                                                                          func (*DB) CreateDoc

                                                                                          func (db *DB) CreateDoc(ctx context.Context, doc interface{}) (docID, rev string, err error)

                                                                                            CreateDoc creates a new doc with an auto-generated unique ID. The generated docID and new rev are returned.

                                                                                            func (*DB) CreateIndex

                                                                                            func (db *DB) CreateIndex(ctx context.Context, ddoc, name string, index interface{}) error

                                                                                              CreateIndex creates an index if it doesn't already exist. ddoc and name may be empty, in which case they will be auto-generated. index must be a valid index object, as described here: http://docs.couchdb.org/en/2.0.0/api/database/find.html#find-sort

                                                                                              func (*DB) Delete

                                                                                              func (db *DB) Delete(ctx context.Context, docID, rev string) (newRev string, err error)

                                                                                                Delete marks the specified document as deleted.

                                                                                                func (*DB) DeleteAttachment

                                                                                                func (db *DB) DeleteAttachment(ctx context.Context, docID, rev, filename string) (newRev string, err error)

                                                                                                  DeleteAttachment delets an attachment from a document, returning the document's new revision.

                                                                                                  func (*DB) DeleteIndex

                                                                                                  func (db *DB) DeleteIndex(ctx context.Context, ddoc, name string) error

                                                                                                    DeleteIndex deletes the requested index.

                                                                                                    func (*DB) Find

                                                                                                    func (db *DB) Find(ctx context.Context, query interface{}) (*Rows, error)

                                                                                                      Find executes a query using the new /_find interface. The query must be JSON-marshalable to a valid query. See http://docs.couchdb.org/en/2.0.0/api/database/find.html#db-find

                                                                                                      func (*DB) Flush

                                                                                                      func (db *DB) Flush(ctx context.Context) error

                                                                                                        Flush requests a flush of disk cache to disk or other permanent storage.

                                                                                                        See http://docs.couchdb.org/en/2.0.0/api/database/compact.html#db-ensure-full-commit

                                                                                                        func (*DB) Get

                                                                                                        func (db *DB) Get(ctx context.Context, docID string, options ...Options) (*Row, error)

                                                                                                          Get fetches the requested document.

                                                                                                          func (*DB) GetAttachment

                                                                                                          func (db *DB) GetAttachment(ctx context.Context, docID, rev, filename string) (*Attachment, error)

                                                                                                            GetAttachment returns a file attachment associated with the document.

                                                                                                            func (*DB) GetAttachmentMeta

                                                                                                            func (db *DB) GetAttachmentMeta(ctx context.Context, docID, rev, filename string) (*Attachment, error)

                                                                                                              GetAttachmentMeta returns meta data about an attachment. The attachment content returned will be empty.

                                                                                                              func (*DB) GetIndexes

                                                                                                              func (db *DB) GetIndexes(ctx context.Context) ([]Index, error)

                                                                                                                GetIndexes returns the indexes defined on the current database.

                                                                                                                func (*DB) Put

                                                                                                                func (db *DB) Put(ctx context.Context, docID string, doc interface{}) (rev string, err error)

                                                                                                                  Put creates a new doc or updates an existing one, with the specified docID. If the document already exists, the current revision must be included in doc, with JSON key '_rev', otherwise a conflict will occur. The new rev is returned.

                                                                                                                  func (*DB) PutAttachment

                                                                                                                  func (db *DB) PutAttachment(ctx context.Context, docID, rev string, att *Attachment) (newRev string, err error)

                                                                                                                    PutAttachment uploads the supplied content as an attachment to the specified document.

                                                                                                                    func (*DB) Query

                                                                                                                    func (db *DB) Query(ctx context.Context, ddoc, view string, options ...Options) (*Rows, error)

                                                                                                                      Query executes the specified view function from the specified design document. ddoc and view may or may not be be prefixed with '_design/' and '_view/' respectively. No other

                                                                                                                      func (*DB) Rev

                                                                                                                      func (db *DB) Rev(ctx context.Context, docID string) (rev string, err error)

                                                                                                                        Rev returns the most current rev of the requested document. This can be more efficient than a full document fetch, becuase only the rev is fetched from the server.

                                                                                                                        func (*DB) Security

                                                                                                                        func (db *DB) Security(ctx context.Context) (*Security, error)

                                                                                                                          Security returns the database's security document. See http://couchdb.readthedocs.io/en/latest/api/database/security.html#get--db-_security

                                                                                                                          func (*DB) SetSecurity

                                                                                                                          func (db *DB) SetSecurity(ctx context.Context, security *Security) error

                                                                                                                            SetSecurity sets the database's security document. See http://couchdb.readthedocs.io/en/latest/api/database/security.html#put--db-_security

                                                                                                                            func (*DB) Stats

                                                                                                                            func (db *DB) Stats(ctx context.Context) (*DBStats, error)

                                                                                                                              Stats returns database statistics.

                                                                                                                              func (*DB) ViewCleanup

                                                                                                                              func (db *DB) ViewCleanup(ctx context.Context) error

                                                                                                                                ViewCleanup removes view index files that are no longer required as a result of changed views within design documents. See http://docs.couchdb.org/en/2.0.0/api/database/compact.html#db-view-cleanup

                                                                                                                                type DBStats

                                                                                                                                type DBStats struct {
                                                                                                                                	// Name is the name of the database.
                                                                                                                                	Name string `json:"db_name"`
                                                                                                                                	// CompactRunning is true if the database is currently being compacted.
                                                                                                                                	CompactRunning bool `json:"compact_running"`
                                                                                                                                	// DocCount is the number of documents are currently stored in the database.
                                                                                                                                	DocCount int64 `json:"doc_count"`
                                                                                                                                	// DeletedCount is a count of documents which have been deleted from the
                                                                                                                                	// database.
                                                                                                                                	DeletedCount int64 `json:"doc_del_count"`
                                                                                                                                	// UpdateSeq is the current update sequence for the database.
                                                                                                                                	UpdateSeq string `json:"update_seq"`
                                                                                                                                	// DiskSize is the number of bytes used on-disk to store the database.
                                                                                                                                	DiskSize int64 `json:"disk_size"`
                                                                                                                                	// ActiveSize is the number of bytes used on-disk to store active documents.
                                                                                                                                	// If this number is lower than DiskSize, then compaction would free disk
                                                                                                                                	// space.
                                                                                                                                	ActiveSize int64 `json:"data_size"`
                                                                                                                                	// ExternalSize is the size of the documents in the database, as represented
                                                                                                                                	// as JSON, before compression.
                                                                                                                                	ExternalSize int64 `json:"-"`
                                                                                                                                }

                                                                                                                                  DBStats contains database statistics..

                                                                                                                                  type DBUpdates

                                                                                                                                  type DBUpdates struct {
                                                                                                                                  	// contains filtered or unexported fields
                                                                                                                                  }

                                                                                                                                    DBUpdates provides access to database updates.

                                                                                                                                    func (*DBUpdates) Close

                                                                                                                                    func (f *DBUpdates) Close() error

                                                                                                                                      Close closes the feed. Any unread updates will still be accessible via Next().

                                                                                                                                      func (*DBUpdates) DBName

                                                                                                                                      func (f *DBUpdates) DBName() string

                                                                                                                                        DBName returns the database name for the current update.

                                                                                                                                        func (*DBUpdates) Err

                                                                                                                                        func (f *DBUpdates) Err() error

                                                                                                                                          Err returns the error, if any, that was encountered during iteration. Err may be called after an explicit or implicit Close.

                                                                                                                                          func (*DBUpdates) Next

                                                                                                                                          func (f *DBUpdates) Next() bool

                                                                                                                                            Next returns the next DBUpdate from the feed. This function will block until an event is received. If an error occurs, it will be returned and the feed closed. If the feed was closed normally, io.EOF will be returned when there are no more events in the buffer.

                                                                                                                                            func (*DBUpdates) Seq

                                                                                                                                            func (f *DBUpdates) Seq() string

                                                                                                                                              Seq returns the update sequence of the current update.

                                                                                                                                              func (*DBUpdates) Type

                                                                                                                                              func (f *DBUpdates) Type() string

                                                                                                                                                Type returns the type of the current update.

                                                                                                                                                type Index

                                                                                                                                                type Index struct {
                                                                                                                                                	DesignDoc  string      `json:"ddoc,omitempty"`
                                                                                                                                                	Name       string      `json:"name"`
                                                                                                                                                	Type       string      `json:"type"`
                                                                                                                                                	Definition interface{} `json:"def"`
                                                                                                                                                }

                                                                                                                                                  Index is a MonboDB-style index definition.

                                                                                                                                                  type MD5sum

                                                                                                                                                  type MD5sum [16]byte

                                                                                                                                                    MD5sum is a 128-bit MD5 checksum.

                                                                                                                                                    type Members

                                                                                                                                                    type Members struct {
                                                                                                                                                    	Names []string `json:"names,omitempty"`
                                                                                                                                                    	Roles []string `json:"roles,omitempty"`
                                                                                                                                                    }

                                                                                                                                                      Members represents the members of a database security document.

                                                                                                                                                      type Options

                                                                                                                                                      type Options map[string]interface{}

                                                                                                                                                        Options is a collection of options. The keys and values are backend specific.

                                                                                                                                                        type Replication

                                                                                                                                                        type Replication struct {
                                                                                                                                                        	Source string
                                                                                                                                                        	Target string
                                                                                                                                                        	// contains filtered or unexported fields
                                                                                                                                                        }

                                                                                                                                                          Replication represents a CouchDB replication process.

                                                                                                                                                          func (*Replication) Delete

                                                                                                                                                          func (r *Replication) Delete(ctx context.Context) error

                                                                                                                                                            Delete deletes a replication. If it is currently running, it will be cancelled.

                                                                                                                                                            func (*Replication) DocWriteFailures

                                                                                                                                                            func (r *Replication) DocWriteFailures() int64

                                                                                                                                                              DocWriteFailures returns the number of doc write failures, if known.

                                                                                                                                                              func (*Replication) DocsRead

                                                                                                                                                              func (r *Replication) DocsRead() int64

                                                                                                                                                                DocsRead returns the number of documents read, if known.

                                                                                                                                                                func (*Replication) DocsWritten

                                                                                                                                                                func (r *Replication) DocsWritten() int64

                                                                                                                                                                  DocsWritten returns the number of documents written, if known.

                                                                                                                                                                  func (*Replication) EndTime

                                                                                                                                                                  func (r *Replication) EndTime() time.Time

                                                                                                                                                                    EndTime returns the replication end time, once the replication has terminated.

                                                                                                                                                                    func (*Replication) Err

                                                                                                                                                                    func (r *Replication) Err() error

                                                                                                                                                                      Err returns the error, if any, that caused the replication to abort.

                                                                                                                                                                      func (*Replication) IsActive

                                                                                                                                                                      func (r *Replication) IsActive() bool

                                                                                                                                                                        IsActive returns true if the replication has not yet completed or errored.

                                                                                                                                                                        func (*Replication) Progress

                                                                                                                                                                        func (r *Replication) Progress() float64

                                                                                                                                                                          Progress returns the current replication progress, if known.

                                                                                                                                                                          func (*Replication) ReplicationID

                                                                                                                                                                          func (r *Replication) ReplicationID() string

                                                                                                                                                                            ReplicationID returns the _replication_id field of the replicator document.

                                                                                                                                                                            func (*Replication) StartTime

                                                                                                                                                                            func (r *Replication) StartTime() time.Time

                                                                                                                                                                              StartTime returns the replication start time, once the replication has been triggered.

                                                                                                                                                                              func (*Replication) State

                                                                                                                                                                              func (r *Replication) State() ReplicationState

                                                                                                                                                                                State returns the current replication state

                                                                                                                                                                                func (*Replication) Update

                                                                                                                                                                                func (r *Replication) Update(ctx context.Context) error

                                                                                                                                                                                  Update requests a replication state update from the server. If there is an error retrieving the update, it is returned and the replication state is unaltered.

                                                                                                                                                                                  type ReplicationInfo

                                                                                                                                                                                  type ReplicationInfo struct {
                                                                                                                                                                                  	DocWriteFailures int64
                                                                                                                                                                                  	DocsRead         int64
                                                                                                                                                                                  	DocsWritten      int64
                                                                                                                                                                                  	Progress         float64
                                                                                                                                                                                  }

                                                                                                                                                                                    ReplicationInfo represents a snapshot of the status of a replication.

                                                                                                                                                                                    type ReplicationState

                                                                                                                                                                                    type ReplicationState string

                                                                                                                                                                                      ReplicationState represents a replication's state

                                                                                                                                                                                      const (
                                                                                                                                                                                      	ReplicationNotStarted ReplicationState = ""
                                                                                                                                                                                      	ReplicationStarted    ReplicationState = "triggered"
                                                                                                                                                                                      	ReplicationError      ReplicationState = "error"
                                                                                                                                                                                      	ReplicationComplete   ReplicationState = "completed"
                                                                                                                                                                                      )

                                                                                                                                                                                        The possible values for the _replication_state field in _replicator documents plus a blank value for unstarted replications.

                                                                                                                                                                                        type Row

                                                                                                                                                                                        type Row struct {
                                                                                                                                                                                        	// contains filtered or unexported fields
                                                                                                                                                                                        }

                                                                                                                                                                                          Row is the result of calling Get for a single document.

                                                                                                                                                                                          func (*Row) ScanDoc

                                                                                                                                                                                          func (r *Row) ScanDoc(dest interface{}) error

                                                                                                                                                                                            ScanDoc unmarshals the data from the fetched row into dest. See documentation on Rows.ScanDoc for details.

                                                                                                                                                                                            type Rows

                                                                                                                                                                                            type Rows struct {
                                                                                                                                                                                            	// contains filtered or unexported fields
                                                                                                                                                                                            }

                                                                                                                                                                                              Rows is an iterator over a a multi-value query.

                                                                                                                                                                                              func (*Rows) Close

                                                                                                                                                                                              func (r *Rows) Close() error

                                                                                                                                                                                                Close closes the Rows, preventing further enumeration, and freeing any resources (such as the http request body) of the underlying query. If Next is called and there are no further results, Rows is closed automatically and it will suffice to check the result of Err. Close is idempotent and does not affect the result of Err.

                                                                                                                                                                                                func (*Rows) Err

                                                                                                                                                                                                func (r *Rows) Err() error

                                                                                                                                                                                                  Err returns the error, if any, that was encountered during iteration. Err may be called after an explicit or implicit Close.

                                                                                                                                                                                                  func (*Rows) ID

                                                                                                                                                                                                  func (r *Rows) ID() string

                                                                                                                                                                                                    ID returns the ID of the current result.

                                                                                                                                                                                                    func (*Rows) Key

                                                                                                                                                                                                    func (r *Rows) Key() string

                                                                                                                                                                                                      Key returns the Key of the current result as a de-quoted JSON object. For compound keys, the ScanKey() method may be more convenient.

                                                                                                                                                                                                      func (*Rows) Next

                                                                                                                                                                                                      func (r *Rows) Next() bool

                                                                                                                                                                                                        Next prepares the next result value for reading. It returns true on success or false if there are no more results or an error occurs while preparing it. Err should be consulted to distinguish between the two.

                                                                                                                                                                                                        func (*Rows) Offset

                                                                                                                                                                                                        func (r *Rows) Offset() int64

                                                                                                                                                                                                          Offset returns the starting offset where the result set started. It is only guaranteed to be set after all result rows have been enumerated through by Next, and thus should only be read after processing all rows in a result set. Calling Close before enumerating will render this value unreliable.

                                                                                                                                                                                                          func (*Rows) ScanDoc

                                                                                                                                                                                                          func (r *Rows) ScanDoc(dest interface{}) error

                                                                                                                                                                                                            ScanDoc works the same as ScanValue, but on the doc field of the result. It is only valid for results that include documents.

                                                                                                                                                                                                            func (*Rows) ScanKey

                                                                                                                                                                                                            func (r *Rows) ScanKey(dest interface{}) error

                                                                                                                                                                                                              ScanKey works the same as ScanValue, but on the key field of the result. For simple keys, which are just strings, the Key() method may be easier to use.

                                                                                                                                                                                                              func (*Rows) ScanValue

                                                                                                                                                                                                              func (r *Rows) ScanValue(dest interface{}) error

                                                                                                                                                                                                                ScanValue copies the data from the result value into the value pointed at by dest. Think of this as a json.Unmarshal into dest.

                                                                                                                                                                                                                If the dest argument has type *[]byte, Scan stores a copy of the input data. The copy is owned by the caller and can be modified and held indefinitely.

                                                                                                                                                                                                                The copy can be avoided by using an argument of type *json.RawMessage instead. After a Scaninto a json.RawMessage, the slice is only valid until the next call to Next, Scan, or Close.

                                                                                                                                                                                                                For all other types, refer to the documentation for json.Unmarshal for type conversion rules.

                                                                                                                                                                                                                func (*Rows) TotalRows

                                                                                                                                                                                                                func (r *Rows) TotalRows() int64

                                                                                                                                                                                                                  TotalRows returns the total number of rows in the view which would have been returned if no limiting were used. This value is only guaranteed to be set after all result rows have been enumerated through by Next, and thus should only be read after processing all rows in a result set. Calling Close before enumerating will render this value unreliable.

                                                                                                                                                                                                                  func (*Rows) UpdateSeq

                                                                                                                                                                                                                  func (r *Rows) UpdateSeq() string

                                                                                                                                                                                                                    UpdateSeq returns the sequence id of the underlying database the view reflects, if requested in the query.

                                                                                                                                                                                                                    type Security

                                                                                                                                                                                                                    type Security struct {
                                                                                                                                                                                                                    	Admins  Members `json:"admins"`
                                                                                                                                                                                                                    	Members Members `json:"members"`
                                                                                                                                                                                                                    }

                                                                                                                                                                                                                      Security represents a database security document.

                                                                                                                                                                                                                      type Version

                                                                                                                                                                                                                      type Version struct {
                                                                                                                                                                                                                      	// Version is the version number reported by the server or backend.
                                                                                                                                                                                                                      	Version string
                                                                                                                                                                                                                      	// Vendor is the vendor string reported by the server or backend.
                                                                                                                                                                                                                      	Vendor string
                                                                                                                                                                                                                      	// RawResponse is the raw response body returned by the server, useful if
                                                                                                                                                                                                                      	// you need additional backend-specific information.
                                                                                                                                                                                                                      	//
                                                                                                                                                                                                                      	// For the format of this document, see
                                                                                                                                                                                                                      	// http://docs.couchdb.org/en/2.0.0/api/server/common.html#get
                                                                                                                                                                                                                      	RawResponse json.RawMessage
                                                                                                                                                                                                                      }

                                                                                                                                                                                                                        Version represents a server version response.

                                                                                                                                                                                                                        Directories

                                                                                                                                                                                                                        Path Synopsis
                                                                                                                                                                                                                        basic
                                                                                                                                                                                                                        Package basic provides HTTP Basic Auth services.
                                                                                                                                                                                                                        Package basic provides HTTP Basic Auth services.
                                                                                                                                                                                                                        cookie
                                                                                                                                                                                                                        Package cookie provides standard CouchDB cookie auth as described at http://docs.couchdb.org/en/2.0.0/api/server/authn.html#cookie-authentication
                                                                                                                                                                                                                        Package cookie provides standard CouchDB cookie auth as described at http://docs.couchdb.org/en/2.0.0/api/server/authn.html#cookie-authentication
                                                                                                                                                                                                                        Package authdb provides a standard interface to an authentication user store to be used by AuthHandlers.
                                                                                                                                                                                                                        Package authdb provides a standard interface to an authentication user store to be used by AuthHandlers.
                                                                                                                                                                                                                        authgroup
                                                                                                                                                                                                                        Package authgroup groups two or more authentication backends together, trying one, then falling through to the others.
                                                                                                                                                                                                                        Package authgroup groups two or more authentication backends together, trying one, then falling through to the others.
                                                                                                                                                                                                                        confadmin
                                                                                                                                                                                                                        Package confadmin provides an authentication service for admins configured in server configuration.
                                                                                                                                                                                                                        Package confadmin provides an authentication service for admins configured in server configuration.
                                                                                                                                                                                                                        couchauth
                                                                                                                                                                                                                        Package couchauth provides auth services to a remote CouchDB server.
                                                                                                                                                                                                                        Package couchauth provides auth services to a remote CouchDB server.
                                                                                                                                                                                                                        usersdb
                                                                                                                                                                                                                        Package usersdb provides auth facilities from a CouchDB _users database.
                                                                                                                                                                                                                        Package usersdb provides auth facilities from a CouchDB _users database.
                                                                                                                                                                                                                        cmd
                                                                                                                                                                                                                        Package driver defines interfaces to be implemented by database drivers as used by package kivik.
                                                                                                                                                                                                                        Package driver defines interfaces to be implemented by database drivers as used by package kivik.
                                                                                                                                                                                                                        common
                                                                                                                                                                                                                        Package common contains logic and data structures shared by various kivik backends.
                                                                                                                                                                                                                        Package common contains logic and data structures shared by various kivik backends.
                                                                                                                                                                                                                        couchdb
                                                                                                                                                                                                                        Package couchdb is a driver for connecting with a CouchDB server over HTTP.
                                                                                                                                                                                                                        Package couchdb is a driver for connecting with a CouchDB server over HTTP.
                                                                                                                                                                                                                        couchdb/chttp
                                                                                                                                                                                                                        Package chttp provides a minimal HTTP driver backend for communicating with CouchDB servers.
                                                                                                                                                                                                                        Package chttp provides a minimal HTTP driver backend for communicating with CouchDB servers.
                                                                                                                                                                                                                        fs
                                                                                                                                                                                                                        Package fs provides a filesystem-backed Kivik driver.
                                                                                                                                                                                                                        Package fs provides a filesystem-backed Kivik driver.
                                                                                                                                                                                                                        memory
                                                                                                                                                                                                                        Package memory provides a memory-backed Kivik driver, intended for testing.
                                                                                                                                                                                                                        Package memory provides a memory-backed Kivik driver, intended for testing.
                                                                                                                                                                                                                        pouchdb/bindings
                                                                                                                                                                                                                        Package bindings provides minimal GopherJS bindings around the PouchDB library.
                                                                                                                                                                                                                        Package bindings provides minimal GopherJS bindings around the PouchDB library.
                                                                                                                                                                                                                        Package errors provides convenience functions for Kivik drivers to report meaningful errors.
                                                                                                                                                                                                                        Package errors provides convenience functions for Kivik drivers to report meaningful errors.
                                                                                                                                                                                                                        db
                                                                                                                                                                                                                        kt
                                                                                                                                                                                                                        Package kt provides common utilities for Kivik tests.
                                                                                                                                                                                                                        Package kt provides common utilities for Kivik tests.