Skip to content

Instantly share code, notes, and snippets.

@glynnbird
Created January 13, 2015 15:47
Show Gist options
  • Save glynnbird/c066472ec20e9bb5610b to your computer and use it in GitHub Desktop.
Save glynnbird/c066472ec20e9bb5610b to your computer and use it in GitHub Desktop.

Writing a record to PouchDB is as simple as including a Javascript file in your HTML:

<script type="text/javascript" src="js/pouchdb-3.0.6.min.js"></script>

and writing a few lines of code

var db = new PouchDB("myfirstdatabase");
var obj = { a:1, b: "2", c: true };
db.post( obj);

Syncing your data with Cloudant is a one-liner:

db.sync("https://u:p@host.cloudant.com/myfirstdatabase", { live: true });

The URL contains the username, password,hostname and database to which data will be synced in both directions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment