Documentation
¶
Index ¶
- type AllDocumentsPagination
- type BulkDocuments
- type Database
- func (db *Database) AllDocuments() (*AllDocumentsPagination, error)
- func (db *Database) AllDocumentsQuery(query *PaginationQuery) (*AllDocumentsPagination, error)
- func (db *Database) Get(id string, rev string) (doc *Document, err error)
- func (db *Database) GetBulkDocumentObject() *BulkDocuments
- func (db *Database) GetByRevision(id string, revision string) (doc *Document, err error)
- func (db *Database) GetDesignDocument(name string) (dd *DesignDocument, err error)
- func (db *Database) GetLatest(id string) (doc *Document, err error)
- func (db *Database) NewDocument() *Document
- func (db *Database) Save(b []byte) (doc *Document, err error)
- func (db *Database) UpdateInfo() (err error)
- type DatabaseInfo
- type DatabaseInfoOther
- type DatabaseInfoSizes
- type DatabaseUpdate
- type DesignDocument
- type DesignDocumentInfo
- type DesignDocumentOptions
- type DesignDocumentRewrite
- type DesignDocumentView
- type DesignDocumentViewIndexInfo
- type DesignDocumentViewRow
- type Document
- func (doc *Document) Copy(targetID string) (*Document, error)
- func (doc *Document) CopyLatest(targetID string) (*Document, error)
- func (doc *Document) CopyRevision(revision string, targetID string) (*Document, error)
- func (doc *Document) Delete() bool
- func (doc *Document) ForceDelete() bool
- func (doc *Document) GetRevisions() (revs map[string]string, err error)
- func (doc *Document) LatestRevision() string
- func (doc *Document) Load() error
- func (doc *Document) Save(b []byte) (err error)
- func (doc *Document) SaveRaw() bool
- type Pagination
- type PaginationJSON
- type PaginationQuery
- type Server
- func (server *Server) Create(name string) (db *Database, err error)
- func (server *Server) Delete(db *Database) (err error)
- func (server *Server) DoCookieAuth() (err error)
- func (server *Server) Exists(name string) (exists bool)
- func (server *Server) Get(name string) (db *Database, err error)
- func (server *Server) GetActiveTasks() (tasks []ServerActiveTask, err error)
- func (server *Server) GetAllDatabaseUpdates() (updates []DatabaseUpdate, err error)
- func (server *Server) GetAllDatabases() (names []string, err error)
- func (server *Server) GetMembership() (memberships map[string][]string, err error)
- func (server *Server) GetOrCreate(name string) (db *Database, err error)
- func (server *Server) GetSession() (ses *Session, err error)
- func (server *Server) GetUUID() (string, error)
- func (server *Server) GetUUIDs(count int) ([]string, error)
- func (server *Server) HTTPCopy(path string, destinationDocumentID string) (status int, header *http.Header, body string, err error)
- func (server *Server) HTTPDelete(path string) (status int, header *http.Header, body string, err error)
- func (server *Server) HTTPGet(path string) (status int, header *http.Header, body string, err error)
- func (server *Server) HTTPHead(path string) (status int, header *http.Header, err error)
- func (server *Server) HTTPPost(path string, inBody io.Reader) (status int, header *http.Header, body string, err error)
- func (server *Server) HTTPPut(path string, inBody io.Reader) (status int, header *http.Header, body string, err error)
- func (server *Server) Info() (info *ServerInfo, err error)
- func (server *Server) IsAuthenticated() bool
- func (server *Server) Replicate(source string, target string) (err error)
- func (server *Server) SetCookieAuth(username string, password string)
- type ServerActiveTask
- type ServerInfo
- type ServerInfoVendor
- type Session
- type SessionUserContext
- type ViewPagination
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllDocumentsPagination ¶
type AllDocumentsPagination struct {
Pagination // Interface
PaginationJSON // JSON Variables used by pagination views
Query *PaginationQuery `json:"-"` // Variables
// contains filtered or unexported fields
}
AllDocumentsPagination is an object used for pagination of _all_docs.
func (*AllDocumentsPagination) Load ¶
func (ad *AllDocumentsPagination) Load() error
Load retrieves data based on the current settings within the view.
func (*AllDocumentsPagination) Next ¶
func (ad *AllDocumentsPagination) Next() error
Next performs a Load after moving skip forward based on the limit. If the limit is 0 nothing happens.
func (*AllDocumentsPagination) Previous ¶
func (ad *AllDocumentsPagination) Previous() error
Previous performs a Load after moving skip back based on the limit. Where limit is 0 but skip is not the query just sets skip to 0 and loads.
type BulkDocuments ¶
type BulkDocuments struct {
Database *Database `json:"-"`
AllOrNothing bool `json:"all_or_nothing"`
NewEdits bool `json:"new_edits"`
Documents []map[string]json.Token `json:"docs"`
}
BulkDocuments represents a collection of documents to be saved, updated, or added, in bulk. Contrary to the Save functions in let, BulkDocuments functions have no default safety on the Save function.
func (*BulkDocuments) Save ¶
func (bd *BulkDocuments) Save() error
Save triggers a bulk save function sent to _bulk_docs.
type Database ¶
type Database struct {
Name string // name
Info DatabaseInfo // Information
// contains filtered or unexported fields
}
Database represents a CouchDB Database (tied to a Server object)
func (*Database) AllDocuments ¶
func (db *Database) AllDocuments() (*AllDocumentsPagination, error)
AllDocuments returns a list of all documents (as per _all_docs)
func (*Database) AllDocumentsQuery ¶
func (db *Database) AllDocumentsQuery(query *PaginationQuery) (*AllDocumentsPagination, error)
AllDocumentsQuery returns a list of all documents (as per _all_docs) based on the query object.
func (*Database) Get ¶
Get retreives a document (if it exists), or an error if it does not. _id and _rev must be provided (via id and rev); a blank _rev will trigger the latest.
func (*Database) GetBulkDocumentObject ¶
func (db *Database) GetBulkDocumentObject() *BulkDocuments
GetBulkDocumentObject returns an empty BulkDocuments object pointing to the given database.
func (*Database) GetByRevision ¶
GetByRevision returns a document based on revision
func (*Database) GetDesignDocument ¶
func (db *Database) GetDesignDocument(name string) (dd *DesignDocument, err error)
GetDesignDocument returns a given design document (if it exists).
func (*Database) GetLatest ¶
GetLatest gets the latest version of a document (if it exists). _id must be provided (via id)
func (*Database) NewDocument ¶
NewDocument creates an empty document bound to the database.
func (*Database) UpdateInfo ¶
UpdateInfo performs an update on the information (via GET request)
type DatabaseInfo ¶
type DatabaseInfo struct {
Name string `json:"db_name"` // Name of the database
UpdateSequenceNumber string `json:"update_seq"` // The current number of updates to the database.
Sizes DatabaseInfoSizes `json:"sizes"` // Sizes (not described in the docs (yet))
PurgeSequenceNumber uint64 `json:"purge_seq"` // The number of purge operations on the database.
Other DatabaseInfoOther `json:"other"` // Other (not described in the docs (yet))
DocumentDeleteCount uint64 `json:"doc_del_count"` // Number of deleted documents
DocumentCount uint64 `json:"doc_count"` // A count of the documents in the specified database.
SizeOnDisk uint64 `json:"disk_size"` // The length of the database file on disk; Views indexes are not included in the calculation.
DiskFormatVersion uint64 `json:"disk_format_version"` // The version of the physical format used for; the data when it is stored on disk.
DataSize uint64 `json:"data_size"` // The number of bytes of live data inside the database file.
CompactRunning bool `json:"compact_running"` // Set to true if the database compaction routine is operating on this database.
InstanceStartTime string `json:"instance_start_time"` // Timestamp of when the database was opened, expressed in microseconds since the epoch.
}
DatabaseInfo is a json de/serialisation object JSON reply from CouchDB 2.0 - as of 2015/09/21
type DatabaseInfoOther ¶
type DatabaseInfoOther struct {
Size uint64 `json:"data_size"`
}
DatabaseInfoOther is a json de/serialisation object representing _info["other"]
type DatabaseInfoSizes ¶
DatabaseInfoSizes is a json de/serialisation object representing _info["sizes"].
type DatabaseUpdate ¶
type DatabaseUpdate struct {
// Database name
DatabaseName string `json:"db_name"`
// Event operation status
OK bool
// A database event; one of created, updated, deleted
Type string
}
DatabaseUpdate is a Go struct representing _db_updates
type DesignDocument ¶
type DesignDocument struct {
Name string `json:"-"` // Design document name
Path string `json:"-"` // Design document path
Language string `json:"language"` // Language (defaults to JavaScript if missing)
Options DesignDocumentOptions `json:"options"` // Default options (not yet implemented)
Filters map[string]string `json:"filters"` // Key is the function name; value is a function's source (stringified)
Lists map[string]string `json:"lists"` // Key is the function name; value is a function's source (stringified)
Rewrites []*DesignDocumentRewrite `json:"rewrites"` // From/To (as per the docs)
Shows map[string]string `json:"shows"` // Key is the function name; value is a function's source (stringified)
Updates map[string]string `json:"updates"` // "Update functions definition"
Views map[string]*DesignDocumentView `json:"views"` // Views
ValidateDocUpdates string `json:"validate_doc_update"` // Validate document update function source; value is a function's source (stringified)
// contains filtered or unexported fields
}
DesignDocument represents the data found in a design document.
func (*DesignDocument) GetView ¶
func (dd *DesignDocument) GetView(name string) (*DesignDocumentView, error)
GetView obtains a design document.
func (*DesignDocument) Info ¶
func (dd *DesignDocument) Info() (*DesignDocumentInfo, error)
Info returns `/db/_design/design-doc/_info`
func (*DesignDocument) Reload ¶
func (dd *DesignDocument) Reload() (err error)
Reload triggers a reload.
func (*DesignDocument) Save ¶
func (dd *DesignDocument) Save() (err error)
Save stores a design document (using raw data).
func (*DesignDocument) String ¶
func (dd *DesignDocument) String() string
String performs stringification for sprintf (etc.)
type DesignDocumentInfo ¶
type DesignDocumentInfo struct {
Name string `json:"name"` // Name
ViewIndex DesignDocumentViewIndexInfo `json:"view_index"` // View Index
}
DesignDocumentInfo represents values returned by `/db/_design/design-doc/_info`
type DesignDocumentOptions ¶
type DesignDocumentOptions struct {
}
DesignDocumentOptions represents the Options stored within a design document.
type DesignDocumentRewrite ¶
type DesignDocumentRewrite struct {
From string `json:"from"`
To string `json:"to"`
Method string `json:"method"`
Query string `json:"query"`
}
DesignDocumentRewrite represents a rewrite rule from a design document.
type DesignDocumentView ¶
type DesignDocumentView struct {
Name string `json:"-"` // Name
Map string `json:"map"`
Reduce string `json:"reduce"`
// contains filtered or unexported fields
}
DesignDocumentView represents a view function from a design document.
func (*DesignDocumentView) Get ¶
func (dv *DesignDocumentView) Get() (*ViewPagination, error)
Get returns the first page using default options (no skip, no key, no limit)
func (*DesignDocumentView) Query ¶
func (dv *DesignDocumentView) Query(query *PaginationQuery) (*ViewPagination, error)
Query uses a Query object (`PaginationQuery`) to perform a guided query.
func (*DesignDocumentView) Save ¶
func (dv *DesignDocumentView) Save() (err error)
Save triggers a design document save (which should encompass the view)
func (*DesignDocumentView) String ¶
func (dv *DesignDocumentView) String() string
String performs stringification for sprintf (etc.)
type DesignDocumentViewIndexInfo ¶
type DesignDocumentViewIndexInfo struct {
CompactRunning bool `json:"compact_running"`
DataSize int `json:"data_size"`
DiskSize int `json:"disk_size"`
Language string `json:"language"`
PurgeSequence string `json:"purge_seq"`
Signature string `json:"signature"`
UpdateSequence int `json:"update_seq"`
UpdaterRunning bool `json:"updater_running"`
WaitingClients int `json:"waiting_clients"`
WaitingCommit bool `json:"waiting_commit"`
}
DesignDocumentViewIndexInfo represents values returned by the view_index field of `/db/_design/design-doc/_info`
type DesignDocumentViewRow ¶
type DesignDocumentViewRow struct {
ID string `json:"id"`
Key json.Token `json:"key"`
Value json.Token `json:"value"`
}
DesignDocumentViewRow represents a row of data within a view.
type Document ¶
type Document struct {
ID string `json:"_id"` // ID (_id) field
Revision string `json:"_rev,omitempty"` // Revision (_rev) field
RawDocument string `json:"-"` // Raw document as string (for printing or json-related use)
// contains filtered or unexported fields
}
Document is a json de/serialisation object of a CouchDB document. It only contains _id and _rev; the RawDocument should be used by your application.
func (*Document) Copy ¶
Copy performs a copy based on the stored revision. The returned document pointer is to the NEW document
func (*Document) CopyLatest ¶
CopyLatest performs a copy from the current document based on the latest revision. The returned document pointer is to the NEW document
func (*Document) CopyRevision ¶
CopyRevision performs a copy from the current document based on the given revision. The returned document is the NEW document and not the current document.
func (*Document) Delete ¶
Delete attempts to remove the document based on the internal revision data. Errors are irrelevent here; all the user needs is 'did it happen?'
func (*Document) ForceDelete ¶
ForceDelete attempts to remove the document regardless of revision.
func (*Document) GetRevisions ¶
GetRevisions performs a revs_info lookup to find all available revisions.
func (*Document) LatestRevision ¶
LatestRevision fetches the highest revision value. In the event of a collision the first found will be returned.
func (*Document) Load ¶
Load retrieves the RawDocument data for processing (based on ID and Revision fields)
func (*Document) Save ¶
Save stores the document based on raw data; this will overwrite the RawDocument and update _id and _rev on success. If _id and/or _rev or invalid they will be added, updated, or removed (as appropriate).
func (*Document) SaveRaw ¶
SaveRaw saves the document based on current content (RawDocument). If successful it will do an internal update; on failure it returns false. This is a semi-legacy interface; it has been kept for weird use-cases.
As with delete a fault is logged if present. Errors are irrelevent here; all the user needs is 'did it happen?'
type Pagination ¶
type Pagination interface {
Load() error // Data is loaded.
Next() error // Skip moves up by limit and the next page is loaded.
Previous() error // Skip moves down by limit (or to 0) and the previous page is loaded.
}
Pagination is an interface which is designed to cover all common pagination requests.
type PaginationJSON ¶
type PaginationJSON struct {
Total int `json:"total_rows"` // total_rows field
Skip int `json:"offset"` // offset field
Rows []*DesignDocumentViewRow `json:"rows"` // rows field
}
PaginationJSON describes common variables
type PaginationQuery ¶
type PaginationQuery struct {
Conflicts bool
Descending bool
EndKey string
EndKeyDocID string
Group bool
GroupLevel int
IncludeDocuments bool
Attachments bool
AttachmentEncodingInfo bool
InclusiveEnd bool
Key string
Keys []string
Limit int
Reduce bool
Skip int
Stale string
StartKey string
StartKeyDocID string
UpdateSequence bool
}
PaginationQuery represents the full range of options which may be queried. See: http://docs.couchdb.org/en/latest/api/ddoc/views.html
func (*PaginationQuery) String ¶
func (pq *PaginationQuery) String() string
String turns a pagination query into a string (using fmt.Sprintf)
type Server ¶
type Server struct {
// In the format of http(s)://<host>:<port>(/<prefix>)
// Should not contain a trailing slash;
// prefix only where required (multiple DBs on the virtual hosts, etc.)
ServerURL string
// HTTP Client
ClientHTTP *http.Client
// contains filtered or unexported fields
}
Server connection (non-SSL)
func ConnectTLS ¶
func ConnectTLS(uri string, certFile string, keyFile string, caFile string) (server *Server, err error)
ConnectTLS creates a server connection with TLS is available; if the TLS fields are blank (i.e. "") a non-TLS connection is used.
This connection call should be used when the application is unsure and is using a configuration file to load the server.
func (*Server) DoCookieAuth ¶
DoCookieAuth performs the authentication (based on stored credentials). Typically `SetCookieAuth` should be used directly; this function should only be used to handle authentication timeouts (verifiable using `IsAuthenticated`).
func (*Server) Get ¶
Get returns an existing database (it does not attempt to create if the requested database is not found).
func (*Server) GetActiveTasks ¶
func (server *Server) GetActiveTasks() (tasks []ServerActiveTask, err error)
GetActiveTasks returns a list of active server tasks. This is currently untested and has been drafted based on documentation.
func (*Server) GetAllDatabaseUpdates ¶
func (server *Server) GetAllDatabaseUpdates() (updates []DatabaseUpdate, err error)
GetAllDatabaseUpdates lists all updates from _db_updates using a list of DatabaseUpdate objects.
func (*Server) GetAllDatabases ¶
GetAllDatabases returns a list of database names based on _all_dbs; the results may vary based on access control.
func (*Server) GetMembership ¶
GetMembership returns membership information from the _membership API call. It appears to function as intended.
func (*Server) GetOrCreate ¶
GetOrCreate gets a database of the given name; it is created if it is not found and access allows.
func (*Server) GetSession ¶
GetSession gets the current user's session information (or nil and an error if the user is not authenticated).
func (*Server) GetUUID ¶
GetUUID gets a single UUID from the server generator. This function is used by internal functions to avoid using POST for document creation.
func (*Server) HTTPCopy ¶
func (server *Server) HTTPCopy(path string, destinationDocumentID string) (status int, header *http.Header, body string, err error)
HTTPCopy performs the 'COPY' requests returning status code, headers, body, and error (if any).
func (*Server) HTTPDelete ¶
func (server *Server) HTTPDelete(path string) (status int, header *http.Header, body string, err error)
HTTPDelete performs the 'DELETE' requests returning status code, headers, body, and error (if any).
func (*Server) HTTPGet ¶
func (server *Server) HTTPGet(path string) (status int, header *http.Header, body string, err error)
HTTPGet performs the 'GET' requests returning status code, headers, body, and error (if any). path must include the query (if required)
func (*Server) HTTPHead ¶
HTTPHead performs the 'HEAD' requests returning status code, headers, and error (if any).
func (*Server) HTTPPost ¶
func (server *Server) HTTPPost(path string, inBody io.Reader) (status int, header *http.Header, body string, err error)
HTTPPost performs the 'POST' requests returning status code, headers, body, and error (if any).
func (*Server) HTTPPut ¶
func (server *Server) HTTPPut(path string, inBody io.Reader) (status int, header *http.Header, body string, err error)
HTTPPut performs the 'PUT' requests returning status code, headers, body, and error (if any).
func (*Server) Info ¶
func (server *Server) Info() (info *ServerInfo, err error)
Info gets basic server information
func (*Server) IsAuthenticated ¶
IsAuthenticated is a trivial GetSession wrapper to check for an authenticated state against _session.
func (*Server) Replicate ¶
Replicate performs replication between a source and target. This function is untested and has been created based on the documentation.
func (*Server) SetCookieAuth ¶
SetCookieAuth stores and attempts to use the username and password for authentication.
type ServerActiveTask ¶
type ServerActiveTask struct {
//Processed changes
ChangesDone uint64 `json:"changes_done"`
// Source database
Database string
// Process ID
PID string
// Current percentage progress (0-100)
Progress uint8
// Task start time as unix timestamp
StartedOn uint64 `json:"started_on"`
// Task status message
Status string
// Task name
Task string
// Total changes to process
TotalChanges uint64 `json:"total_changes"`
// Operation Type
Type string
// Unix timestamp of last operation update
UpdatedOn uint64 `json:"updated_on"`
}
ServerActiveTask is a representation of the json data Currently unknown if this works.
type ServerInfo ¶
type ServerInfo struct {
// Messaage
CouchDB string
// UUID
Version string
// Vendor information
Vendor ServerInfoVendor
}
ServerInfo provides basic server information.
type ServerInfoVendor ¶
type ServerInfoVendor struct {
// Typically "The Apache Software Foundation"
Name string
}
ServerInfoVendor provides basic information about the vendor of the build.
type Session ¶
type Session struct {
Ok bool
UserData SessionUserContext `json:"userCtx"`
}
Session represents CouchDB session information from _session.
type SessionUserContext ¶
SessionUserContext represents the userCtx information from _session.
type ViewPagination ¶
type ViewPagination struct {
Pagination // Interface
Query *PaginationQuery // Variables
PaginationJSON // JSON Variables used by pagination views
// contains filtered or unexported fields
}
ViewPagination is an object used for pagination of a view.
func (*ViewPagination) Load ¶
func (vp *ViewPagination) Load() error
Load retrieves data based on the current settings within the view.
func (*ViewPagination) Next ¶
func (vp *ViewPagination) Next() error
Next performs a Load after moving skip forward based on the limit. If the limit is 0 nothing happens.
func (*ViewPagination) Previous ¶
func (vp *ViewPagination) Previous() error
Previous performs a Load after moving skip back based on the limit. Where limit is 0 but skip is not the query just sets skip to 0 and loads.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
tests
|
|
|
let-test-admin-check
command
|
|
|
let-test-bulk-check
command
|
|
|
let-test-doc-check
command
|
|
|
let-test-suite
command
|
|
|
let-test-view-check
command
|