Documentation ¶
Overview ¶
Package pillow provides a generic interface to CouchDB.
Index ¶
- func ID(id string) string
- func StatusCode(err error) int
- type Client
- func (client *Client) DSN() string
- func (client *Client) Database(ctx context.Context, name string) (db *DB)
- func (client *Client) ListDatabases(ctx context.Context, options ...map[string]interface{}) (databases []string, err error)
- func (client *Client) Ping(ctx context.Context) (pong bool, err error)
- type ClientOptions
- type CreateDatabaseResponse
- type DB
- func (db *DB) CheckDocument(ctx context.Context, id string, options ...map[string]interface{}) (exists bool, err error)
- func (db *DB) Client() *Client
- func (db *DB) Create(ctx context.Context, options ...map[string]interface{}) (output *CreateDatabaseResponse, err error)
- func (db *DB) CreateDesignDocument(ctx context.Context, document map[string]interface{}, ...) (output map[string]interface{}, err error)
- func (db *DB) CreateDocument(ctx context.Context, document interface{}, options ...map[string]interface{}) (output map[string]interface{}, err error)
- func (db *DB) Delete(ctx context.Context, options ...map[string]interface{}) (output *DeleteDatabaseResponse, err error)
- func (db *DB) DeleteDocument(ctx context.Context, id string, options ...map[string]interface{}) (output map[string]interface{}, err error)
- func (db *DB) Exists(ctx context.Context, options ...map[string]interface{}) (exists bool, err error)
- func (db *DB) ListDocuments(ctx context.Context, options ...map[string]interface{}) (output map[string]interface{}, err error)
- func (db *DB) Name() string
- func (db *DB) Query(ctx context.Context, ddcoc, view string, options ...map[string]interface{}) (output map[string]interface{}, err error)
- func (db *DB) QueryWithJSON(ctx context.Context, query string) (output map[string]interface{}, err error)
- func (db *DB) RetrieveDocument(ctx context.Context, id string, options ...map[string]interface{}) (output map[string]interface{}, err error)
- func (db *DB) UpdateDocument(ctx context.Context, id string, document interface{}, ...) (output map[string]interface{}, err error)
- type DeleteDatabaseResponse
- type Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StatusCode ¶
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:
err := db.Get(context.TODO(), "docID").ScanDoc(&doc) if pillow.StatusCode(err) == pillow.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() (httpStatusCode int) }
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
type CreateDatabaseResponse ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) CheckDocument ¶
func (db *DB) CheckDocument(ctx context.Context, id string, options ...map[string]interface{}) (exists bool, err error)
CheckDocument check doc
func (*DB) Create ¶
func (db *DB) Create(ctx context.Context, options ...map[string]interface{}) (output *CreateDatabaseResponse, err error)
Create {"ok":true} {"error":"file_exists","reason":"The database could not be created, the file already exists."}
func (*DB) CreateDesignDocument ¶
func (*DB) CreateDocument ¶
func (db *DB) CreateDocument(ctx context.Context, document interface{}, options ...map[string]interface{}) (output map[string]interface{}, err error)
CreateDocument create doc
func (*DB) Delete ¶
func (db *DB) Delete(ctx context.Context, options ...map[string]interface{}) (output *DeleteDatabaseResponse, err error)
Delete {"ok":true}
func (*DB) DeleteDocument ¶
func (db *DB) DeleteDocument(ctx context.Context, id string, options ...map[string]interface{}) (output map[string]interface{}, err error)
DeleteDocument delete doc
func (*DB) ListDocuments ¶
func (db *DB) ListDocuments(ctx context.Context, options ...map[string]interface{}) (output map[string]interface{}, err error)
ListDocuments list docs
func (*DB) QueryWithJSON ¶
type DeleteDatabaseResponse ¶
type Error ¶
type Error struct { // HTTPStatus is the HTTP status code associated with this error. Normally // this is the actual HTTP status returned by the server, but in some cases // it may be generated by Kivik directly. Check the FromServer value if // the distinction matters to you. HTTPStatus int // Message is the error message. Message string // Err is the originating error, if any. Err error }
Error represents an error returned by Kivik.
This type definition is not guaranteed to remain stable, or even exported. When examining errors programatically, you should rely instead on the StatusCode() function in this package, rather than on directly observing the fields of this type.
func (*Error) Cause ¶
Cause satisfies the github.com/pkg/errors.causer interface by returning e.Err.
func (*Error) StatusCode ¶
StatusCode returns the HTTP status code associated with the error, or 500 (internal server error), if none.