Documentation ¶
Overview ¶
Package bindings provides minimal GopherJS bindings around the PouchDB library. (https://pouchdb.com/api.html)
Index ¶
- Constants
- func NewPouchError(o *js.Object) error
- func Objectify(i interface{}) (interface{}, error)
- func RecoverError(err *error)
- type DB
- func (db *DB) AllDocs(ctx context.Context, options map[string]interface{}) (*js.Object, error)
- func (db *DB) BulkDocs(ctx context.Context, docs ...interface{}) (result *js.Object, err error)
- func (db *DB) Changes(ctx context.Context, options map[string]interface{}) (changes *js.Object, e error)
- func (db *DB) Compact() error
- func (db *DB) CreateIndex(ctx context.Context, index interface{}) (*js.Object, error)
- func (db *DB) Delete(ctx context.Context, doc interface{}) (rev string, err error)
- func (db *DB) DeleteIndex(ctx context.Context, index interface{}) (*js.Object, error)
- func (db *DB) Destroy(ctx context.Context, options map[string]interface{}) error
- func (db *DB) Find(ctx context.Context, query interface{}) (*js.Object, error)
- func (db *DB) Get(ctx context.Context, docID string, opts map[string]interface{}) (doc []byte, err error)
- func (db *DB) GetAttachment(ctx context.Context, docID, filename string, options map[string]interface{}) (*js.Object, error)
- func (db *DB) GetIndexes(ctx context.Context) (*js.Object, error)
- func (db *DB) Info(ctx context.Context) (*DBInfo, error)
- func (db *DB) Post(ctx context.Context, doc interface{}) (docID, rev string, err error)
- func (db *DB) Put(ctx context.Context, doc interface{}) (rev string, err error)
- func (db *DB) PutAttachment(ctx context.Context, docID, filename, rev string, body io.Reader, ctype string) (*js.Object, error)
- func (db *DB) Query(ctx context.Context, ddoc, view string, options map[string]interface{}) (*js.Object, error)
- func (db *DB) RemoveAttachment(ctx context.Context, docID, filename, rev string) (*js.Object, error)
- func (db *DB) ViewCleanup() error
- type DBInfo
- type PouchDB
Constants ¶
const ( ReplicationEventChange = "change" ReplicationEventComplete = "complete" ReplicationEventPaused = "paused" ReplicationEventActive = "active" ReplicationEventDenied = "denied" ReplicationEventError = "error" )
Replication events
Variables ¶
This section is empty.
Functions ¶
func Objectify ¶
func Objectify(i interface{}) (interface{}, error)
Objectify unmarshals a string, []byte, or json.RawMessage into an interface{}. All other types are just passed through.
func RecoverError ¶
func RecoverError(err *error)
RecoverError recovers from a thrown JS error. If an error is caught, err is set to its value.
To use, put this at the beginning of a function:
defer RecoverError(&err)
Types ¶
type DB ¶
DB is a PouchDB database object.
func (*DB) BulkDocs ¶
BulkDocs creates, updates, or deletes docs in bulk. See https://pouchdb.com/api.html#batch_create
func (*DB) Changes ¶
func (db *DB) Changes(ctx context.Context, options map[string]interface{}) (changes *js.Object, e error)
Changes returns an event emitter object.
func (*DB) Compact ¶
Compact compacts the database, and waits for it to complete. This may take a long time! Please wrap this call in a goroutine.
func (*DB) CreateIndex ¶
CreateIndex creates an index to be used by MongoDB-style queries with the pouchdb-find plugin, if it is installed. If the plugin is not installed, a NotImplemented error will be returned.
func (*DB) Delete ¶
Delete marks a document as deleted. See https://pouchdb.com/api.html#delete_document
func (*DB) DeleteIndex ¶
DeleteIndex deletes an index used by the MongoDB-style queries with the pouchdb-find plugin, if it is installed. If the plugin is not installed, a NotImplemeneted error will be returned.
func (*DB) Find ¶
Find executes a MongoDB-style find query with the pouchdb-find plugin, if it is installed. If the plugin is not installed, a NotImplemented error will be returned.
func (*DB) Get ¶
func (db *DB) Get(ctx context.Context, docID string, opts map[string]interface{}) (doc []byte, err error)
Get fetches the requested document from the database. See https://pouchdb.com/api.html#fetch_document
func (*DB) GetAttachment ¶
func (db *DB) GetAttachment(ctx context.Context, docID, filename string, options map[string]interface{}) (*js.Object, error)
GetAttachment returns attachment data.
func (*DB) GetIndexes ¶
GetIndexes returns the list of currently defined indexes on the database.
func (*DB) Post ¶
Post creates a new document and lets PouchDB auto-generate the ID. See https://pouchdb.com/api.html#using-dbpost
func (*DB) Put ¶
Put creates a new document or update an existing document. See https://pouchdb.com/api.html#create_document
func (*DB) PutAttachment ¶
func (db *DB) PutAttachment(ctx context.Context, docID, filename, rev string, body io.Reader, ctype string) (*js.Object, error)
PutAttachment attaches a binary object to a document.
func (*DB) Query ¶
func (db *DB) Query(ctx context.Context, ddoc, view string, options map[string]interface{}) (*js.Object, error)
Query queries a map/reduce function.
func (*DB) RemoveAttachment ¶
func (db *DB) RemoveAttachment(ctx context.Context, docID, filename, rev string) (*js.Object, error)
RemoveAttachment deletes an attachment from a document.
func (*DB) ViewCleanup ¶
ViewCleanup cleans up views, and waits for it to complete. This may take a long time! Please wrap this call in a goroutine.
type DBInfo ¶
type DBInfo struct { *js.Object Name string `js:"db_name"` DocCount int64 `js:"doc_count"` UpdateSeq string `js:"update_seq"` }
DBInfo is a struct respresenting information about a specific database.
type PouchDB ¶
PouchDB represents a PouchDB constructor.
func Defaults ¶
Defaults returns a new PouchDB constructor with the specified default options. See https://pouchdb.com/api.html#defaults