Coder Social home page Coder Social logo

nativescript-couchdb's Introduction

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

nativescript-couchdb's People

Contributors

dependabot[bot] avatar paragasu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ozgursel

nativescript-couchdb's Issues

Support PouchDB?

Can this plugin support PouchDB ?
Because I want to use PouchDB offline, and to sync CouchDB online.
thanks.

CouchDB sync

If this is compatible with PouchDB, can i use syncing to sync my local db with remote CouchDB server?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.