Get started with pouchdb CDN

Apache-2.0 licensed

JS database: PouchDB syncs changes with CouchDB or other PouchDB instances via replication.

Tags:
  • db
  • couchdb
  • pouchdb

Stable version

Copied!

How to start using pouchdb CDN


// Include PouchDB from the CDN
const PouchDB = require('pouchdb')(window.PouchDB.noConflict(true).constructor);

// Initialize a new database instance
const db = new PouchDB('myDatabaseName');

// Save a document
db.put({
  title: 'Hello PouchDB',
  content: 'This is a sample document.'
})
.then(function(response) {
  console.log('Document saved with ID:', response.id);
})
.catch(function(err) {
  console.error('Error saving document:', err);
});

// Get a document
db.get('myDocumentId')
.then(function(doc) {
  console.log('Retrieved document:', doc);
})
.catch(function(err) {
  console.error('Error retrieving document:', err);
});
Copied!
Copied!

All versions