Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nativescript-couchdb

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-couchdb

Couchdb plugin for nativescript

  • 0.6.23
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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)

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));

Keywords

FAQs

Package last updated on 08 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc