Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 

pouchdb-electron

PouchDB works great with Electron (formerly known as Atom Shell). Here's how to get started.

Demo app

Installation

To use PouchDB in your Electron app, just download pouchdb.js and include it in your index.html:

<script src="path/to/pouchdb.js"></script>

Alternatively - the npm package pouchdb-browser can be installed and required in the usual way. Note that the pouchdb package will always attempt to use a LevelDB adapter.

import PouchDB from 'pouchdb-browser' 

Now PouchDB is available as a global variable. So you can create an IndexedDB-based PouchDB:

var db = new PouchDB('mydb');

or a WebSQL-based PouchDB:

var db = new PouchDB('mydb', {adapter: 'websql'});

Use whichever one you prefer. They both work the same, although in my experience WebSQL is slightly faster than IndexedDB in Chromium, for most use cases. (Electron is based on Chromium.)

Using LevelDB via LevelDOWN

You can also use PouchDB in a Node.js style with the LevelDB adapter:

var PouchDB = require('pouchdb');
var db = new PouchDB('mydb');

However, you will have to rebuild the LevelDB binaries for Electron. The demo app shows how to accomplish this.

Basically you will need to run electron-rebuild as a postinstall step. If you are unable to get this to work properly for all your target environments, then you may need to just stick with the in-browser IndexedDB or WebSQL adapters, and avoid the native LevelDB or SQLite (node-websql) adapters.

Note: If you're getting an IO Error:/OpenError after packaging your app, you'll need to make sure you set the database directory explicitly (using require('path') and __dirname, for example, like var db = new PouchDB(path.join(__dirname, 'mydb'))).

About

PouchDB for Electron (formerly Atom Shell)

Resources

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •