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

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

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

func Open

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

Open a database.

func (*Couchstore) Bulk

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

func (db *Couchstore) Close() error

Close the database.

func (*Couchstore) Commit

func (db *Couchstore) Commit() error

Commit pending data.

func (*Couchstore) CompactTo

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

Compact this DB to a new file.

func (*Couchstore) Delete

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

Delete a document.

func (*Couchstore) Get

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

Retrieve a document.

func (*Couchstore) GetFromDocInfo

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

func (*Couchstore) Info

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

Get info about the DB

func (*Couchstore) Set

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

Store a document.

func (*Couchstore) Walk

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

Walk the DB from a specific location.

func (*Couchstore) WalkDocs

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

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

type DBInfo

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

type DocInfo

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

func NewDocInfo

func NewDocInfo(id string, meta uint8) *DocInfo

Create a new docinfo.

func (*DocInfo) ID

func (info *DocInfo) ID() string

Get the ID of this document info

func (*DocInfo) IsDeleted

func (info *DocInfo) IsDeleted() bool

True if this docinfo represents a deleted document.

func (*DocInfo) RevisionSequence

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

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

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

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

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

Walker function that also includes the document.

type Document

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

func NewDocument

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

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

func (*Document) ID

func (doc *Document) ID() string

Get the ID of this document

func (*Document) Value

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

Get the value of this document.

func (*Document) WriteIDTo

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

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

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 3 packages. Updated 2014-01-26. Refresh now. Tools for package owners.