0.6.23 • Published 7 years ago

nativescript-couchdb v0.6.23

Weekly downloads
1
License
Apache-2.0
Repository
-
Last release
7 years ago

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

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)

query(design_view)

  • design_view string eg /_design/design_name/_view/view_name will be design_name/view_name
  • return promise

Usage

import * as dialog from "ui/dialogs";
import { CouchDB } from "nativescript-couchdb";

let db = new CouchDB("https://couchdb.server/dbname", {
  "Authorization": "Basic base64\_encoded\_string"
});
let data = {
  _id: "hello",
  name: "world" 
}


// create and update
db.put(data)
  .then(res => dialog.alert("saved"))
  .catch(err => dialog.alert("Failed"));

// get data
db.get("hello")
  .then(res => dialog.alert(JSON.stringify(res)))
  .catch(err => dialog.alert("Data not found));

// delete doc
db.remove(data)
  .then(res => dialog.alert("Data deleted"))
  .catch(err => dialog.alert("Delete failed"));

// alldocs
db.allDocs(options)
  .then(res => dialog.alert(res))
  .catch(err => dialog.alert(err));

// query views
db.query("user/top_contributor", { group_level: 1, reduce: true })
  .then(res => dialog.alert(res))
  .catch(err => dialog.alert(err));
0.6.23

7 years ago

0.6.22

7 years ago

0.6.21

7 years ago

0.6.20

7 years ago

0.6.19

7 years ago

0.6.18

7 years ago

0.6.17

7 years ago

0.6.16

7 years ago

0.6.15

7 years ago

0.6.14

7 years ago

0.6.13

7 years ago

0.6.12

7 years ago

0.6.11

7 years ago

0.6.10

7 years ago

0.6.9

7 years ago

0.6.8

7 years ago

0.6.7

7 years ago

0.6.5

7 years ago

0.6.4

7 years ago

0.6.3

7 years ago

0.6.2

7 years ago

0.6.1

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago