Documentation
¶
Overview ¶
Package cdb provides the core CouchDB types.
Index ¶
- func EscapeID(s string) string
- func UnescapeID(s string) string
- type Attachment
- type Document
- type FS
- func (fs *FS) NewDocument(docID string) *Document
- func (fs *FS) NewRevision(i interface{}) (*Revision, error)
- func (fs *FS) OpenDocID(docID string, options driver.Options) (*Document, error)
- func (fs *FS) OpenDocIDOpenRevs(docID string, options driver.Options) ([]*Document, error)
- func (fs *FS) ReadSecurity(ctx context.Context, path string) (*driver.Security, error)
- type RevHistory
- type RevID
- type RevInfo
- type RevMeta
- type Revision
- type Revisions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnescapeID ¶
UnescapeID unescapes a filename into a document or database ID.
Types ¶
type Attachment ¶
type Attachment struct { ContentType string `json:"content_type" yaml:"content_type"` RevPos *int64 `json:"revpos,omitempty" yaml:"revpos,omitempty"` Stub bool `json:"stub,omitempty" yaml:"stub,omitempty"` Follows bool `json:"follows,omitempty" yaml:"follows,omitempty"` Content []byte `json:"data,omitempty" yaml:"content,omitempty"` Size int64 `json:"length" yaml:"size"` Digest string `json:"digest" yaml:"digest"` // contains filtered or unexported fields }
Attachment represents a file attachment.
func (*Attachment) MarshalJSON ¶
func (a *Attachment) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*Attachment) Open ¶
func (a *Attachment) Open() (filesystem.File, error)
Open opens the attachment for reading.
type Document ¶
type Document struct { ID string `json:"_id" yaml:"_id"` Revisions Revisions `json:"-" yaml:"-"` // RevsInfo is only used during JSON marshaling when revs_info=true, and // should never be consulted as authoritative. RevsInfo []RevInfo `json:"_revs_info,omitempty" yaml:"-"` // RevHistory is only used during JSON marshaling, when revs=true, and // should never be consulted as authoritative. RevHistory *RevHistory `json:"_revisions,omitempty" yaml:"-"` Options map[string]interface{} `json:"-" yaml:"-"` // contains filtered or unexported fields }
Document is a CouchDB document.
func (*Document) AddRevision ¶
func (d *Document) AddRevision(ctx context.Context, rev *Revision, options driver.Options) (string, error)
AddRevision adds rev to the existing document, according to options, and persists it to disk. The return value is the new revision ID.
func (*Document) Compact ¶
Compact cleans up any non-leaf revs, and attempts to consolidate attachments.
func (*Document) MarshalJSON ¶
MarshalJSON satisfies the json.Marshaler interface.
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
FS provides filesystem access to a
func New ¶
func New(dbroot string, fs ...filesystem.Filesystem) *FS
New initializes a new FS instance, anchored at dbroot. If fs is omitted or nil, the default is used.
func (*FS) NewDocument ¶
NewDocument creates a new document.
func (*FS) NewRevision ¶
NewRevision creates a new revision from i, according to opts.
func (*FS) OpenDocIDOpenRevs ¶
OpenDocIDOpenRevs opens the requested document by ID (without file extension), same as OpenDocID, however, it honors the open_revs option, to potentially return multiple revisions of the same document.
type RevHistory ¶
type RevHistory struct { Start int64 `json:"start" yaml:"start"` IDs []string `json:"ids" yaml:"ids"` }
RevHistory represents the recent ancestors of a revision.
func (*RevHistory) AddRevision ¶
func (h *RevHistory) AddRevision(rev RevID) *RevHistory
AddRevision returns a new history, with rev added.
func (*RevHistory) Ancestors ¶
func (h *RevHistory) Ancestors() []string
Ancestors returns the full, known revision history, newest first, starting with the current rev.
type RevID ¶
RevID is a CouchDB document revision identifier.
func (RevID) MarshalText ¶
MarshalText satisfies the encoding.TextMarshaler interface.
func (*RevID) UnmarshalJSON ¶
UnmarshalJSON satisfies the json.Unmarshaler interface.
func (*RevID) UnmarshalText ¶
UnmarshalText xatisfies the json.Unmarshaler interface.
type RevMeta ¶
type RevMeta struct { Rev RevID `json:"_rev" yaml:"_rev"` Deleted *bool `json:"_deleted,omitempty" yaml:"_deleted,omitempty"` Attachments map[string]*Attachment `json:"_attachments,omitempty" yaml:"_attachments,omitempty"` RevHistory *RevHistory `json:"_revisions,omitempty" yaml:"_revisions,omitempty"` // contains filtered or unexported fields }
RevMeta is the metadata stored in reach revision.
type Revision ¶
type Revision struct { RevMeta // Data is the normal payload Data map[string]interface{} `json:"-" yaml:"-"` // contains filtered or unexported fields }
Revision is a specific instance of a document.
func (*Revision) AttachmentsIterator ¶
func (r *Revision) AttachmentsIterator() (driver.Attachments, error)
AttachmentsIterator will return a driver.Attachments iterator, if the options permit. If options don't permit, both return values will be nil.
func (*Revision) MarshalJSON ¶
MarshalJSON satisfies the json.Marshaler interface
func (*Revision) UnmarshalJSON ¶
UnmarshalJSON satisfies the json.Unmarshaler interface.
func (*Revision) UnmarshalYAML ¶
UnmarshalYAML satisfies the yaml.Unmarshaler interface.