go-couchstore: github.com/dustin/go-couchstore Index | Files

package couchstore

import "github.com/dustin/go-couchstore"

Couchstore API for go.

Index

Package Files

bulk.go couchstore.go walk.go

Constants

const DocIsCompressed = C.COUCH_DOC_IS_COMPRESSED

Variables

var StopIteration error = couchError(C.COUCHSTORE_ERROR_CANCEL)

Return this error to indicate a walker should stop iterating.

type BulkWriter Uses

type BulkWriter interface {
    // Set a document.
    Set(*DocInfo, *Document)
    // Delete a document.
    Delete(*DocInfo)
    // Commit the current batch.
    Commit() error
    // Shut down this bulk interface.
    Close() error
}

type Couchstore Uses

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

func Open Uses

func Open(pathname string, create bool) (*Couchstore, error)

Open a database.

func (*Couchstore) Bulk Uses

func (db *Couchstore) Bulk() BulkWriter

Get a bulk writer.

You must call Close() on the bulk writer when you're done bulk writing.

func (*Couchstore) Close Uses

func (db *Couchstore) Close() error

Close the database.

func (*Couchstore) Commit Uses

func (db *Couchstore) Commit() error

Commit pending data.

func (*Couchstore) CompactTo Uses

func (db *Couchstore) CompactTo(newfile string) error

Compact this DB to a new file.

func (*Couchstore) Delete Uses

func (db *Couchstore) Delete(id string) error

Delete a document.

func (*Couchstore) Get Uses

func (db *Couchstore) Get(id string) (*Document, *DocInfo, error)

Retrieve a document.

func (*Couchstore) GetFromDocInfo Uses

func (db *Couchstore) GetFromDocInfo(info *DocInfo) (*Document, error)

func (*Couchstore) Info Uses

func (db *Couchstore) Info() (DBInfo, error)

Get info about the DB

func (*Couchstore) Set Uses

func (db *Couchstore) Set(docInfo *DocInfo, doc *Document) error

Store a document.

func (*Couchstore) Walk Uses

func (db *Couchstore) Walk(startkey string, callback WalkFun) error

Walk the DB from a specific location.

func (*Couchstore) WalkDocs Uses

func (db *Couchstore) WalkDocs(startkey string, callback DocWalkFun) error

Walk the DB from a specific location including the complete docs.

type DBInfo Uses

type DBInfo struct {
    LastSeq        uint64
    DocCount       uint64
    DeletedCount   uint64
    SpaceUsed      uint64
    HeaderPosition uint64
}

type DocInfo Uses

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

func NewDocInfo Uses

func NewDocInfo(id string, meta uint8) *DocInfo

Create a new docinfo.

func (*DocInfo) ID Uses

func (info *DocInfo) ID() string

Get the ID of this document info

func (*DocInfo) IsDeleted Uses

func (info *DocInfo) IsDeleted() bool

True if this docinfo represents a deleted document.

func (*DocInfo) RevisionSequence Uses

func (info *DocInfo) RevisionSequence() uint32

The revision sequence number of a stored document. This field is for application use; it defaults to zero but will be persisted if set before storing a document. Its intended purpose is as a revision generation counter, hence the name.

func (*DocInfo) Sequence Uses

func (info *DocInfo) Sequence() uint64

The database sequence number of a stored document. Every revision (including deletion) of any document is assigned a sequence number from a database-wide counter that starts at 1 and increments after every change.

func (*DocInfo) SetRevisionSequence Uses

func (info *DocInfo) SetRevisionSequence(sequence uint32)

Set the revision sequence number of a document. This field is for application use; it defaults to zero but will be persisted if set before storing a document. Its intended purpose is as a revision generation counter, hence the name.

func (*DocInfo) WriteIDTo Uses

func (info *DocInfo) WriteIDTo(w io.Writer) (int, error)

Write the ID of this DocInfo to the given writer.

This performs much better than asking for the string, converting it to bytes, and writing that out to the writer.

type DocWalkFun Uses

type DocWalkFun func(db *Couchstore, di *DocInfo, doc *Document) error

Walker function that also includes the document.

type Document Uses

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

func NewDocument Uses

func NewDocument(id string, value []byte) *Document

Get a new document instance with the given id and value.

func (*Document) ID Uses

func (doc *Document) ID() string

Get the ID of this document

func (*Document) Value Uses

func (doc *Document) Value() []byte

Get the value of this document.

func (*Document) WriteIDTo Uses

func (doc *Document) WriteIDTo(w io.Writer) (int, error)

Write the ID of this Document to the given writer.

This performs much better than asking for the string, converting it to bytes, and writing that out to the writer.

func (*Document) WriteValueTo Uses

func (doc *Document) WriteValueTo(w io.Writer) (int, error)

Write the Value of this Document to the given writer.

This performs much better than asking for the string, converting it to bytes, and writing that out to the writer.

type WalkFun Uses

type WalkFun func(db *Couchstore, di *DocInfo) error

Walker function.

Stops at the end of the DB or on error.

Package couchstore imports 6 packages (graph) and is imported by 2 packages. Updated 2016-07-23. Refresh now. Tools for package owners.