nativescript-couchdb
Nativescript plugin for couchdb A simple wrapper using nativescript http api to implement subset api compatible with PouchDB.
Install
tns plugin install nativescript-couchdb
API
constructor(couchdb_url, extraHeaders) Setup the database to connect to
- url string eg: https://localhost:5984
- extraHeaders Map specify extra map to pass as http header
put(doc)
- doc string valid couchdb json doc with _id key
- return promise
get(docId)
- docId string document id
- return promise
remove(doc)
- doc json object couchdb json db or json with _id, _rev key
- return promise
allDocs(options)
- options json object couchdb params as in http://docs.couchdb.org/en/2.0.0/api/database/bulk-api.html
- return promise
query(design_view)
- design_view string eg /_design/design_name/_view/view_name will be design_name/view_name
- return promise
Usage
;; ; // create and updatedb.putdata .thendialog.alert"saved" .catchdialog.alert"Failed"; // get datadb.get"hello" .thendialog.alertJSON.stringifyres .catchdialog.alert"Data not found)); // delete docdb.removedata .thendialog.alert"Data deleted" .catchdialog.alert"Delete failed"; // alldocsdb.allDocsoptions .thendialog.alertres .catchdialog.alerterr; // query viewsdb.query"user/top_contributor", .thendialog.alertres .catchdialog.alerterr;