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

pouchdb-hoodie-sync

Package Overview
Dependencies
Maintainers
4
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pouchdb-hoodie-sync

Hoodie-like sync API for PouchDB

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

pouchdb-hoodie-sync

Hoodie-like sync API for PouchDB

Build Status Coverage Status Dependency Status devDependency Status

This PouchDB plugin provides simple methods to keep two databases in sync.

Usage

// Initialisation
var db = new PouchDB('dbname')
var api = db.hoodieSync({
  // remote can be
  // - local db name
  // - remote URL
  // - PouchDB instance
  // - a promise that resolves to one of the 3 above
  remote: 'http://example.com/mydb',
  // pass own EventEmitter instance if you want,
  // otherwise creates its own
  emitter: emitter
})

// starts / stops continuous replication
api.connect()
api.disconnect()
api.isConnected()

// resolve with pulled docs[]
api.pull()
api.pull([doc1, id2])

// resolve with pushed docs[]
api.push()
api.push([doc1, id2])

// resolve with synced docs[]
api.sync()
api.sync([doc1, id2])

// events
api.on('pull', function(doc) {})
api.on('push', function(doc) {})
api.on('connect', function() {})
api.on('disconnect', function() {})

If you need to customise the request to the server, e.g. set custom header for authorisation, you can use PouchDB.defaults{ajax}:

var MyPouch = PouchDB.defaults({
  ajax: {
    headers: {
      authorization: 'Basic QWxhZGRpbjpPcGVuU2VzYW1l'
    }
  }
})

In the browser

<script src="pouchdb.js"></script>
<script src="pouchdb-hoodie-sync.js"></script>

In node.js

var PouchDB = require('pouchdb')
PouchDB.plugin( require('pouchdb-hoodie-sync') )

Testing

In Node.js

Run all tests and validates JavaScript Code Style using standard

npm test

To run only the tests

npm run test:node

Run tests from single file

node test/unit/connect-test.js

Contributing

Have a look at the Hoodie project's contribution guidelines. If you want to hang out you can join #hoodie-pouch on our Hoodie Community Slack.

License

Apache 2.0

Keywords

FAQs

Package last updated on 09 Mar 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