:koala: - PouchDB is a pocket-sized database.

Overview

PouchDB – The Database that Syncs!

Build Status Coverage Status Greenkeeper badge npm version jsDelivr Hits

PouchDB is an open-source JavaScript database inspired by Apache CouchDB that is designed to run well within the browser.

PouchDB was created to help web developers build applications that work as well offline as they do online.

Using PouchDB

To get started using PouchDB, check out the web site and API documentation.

Getting Help

The PouchDB community is active on Freenode IRC, in the Google Groups mailing list, and on StackOverflow. Or you can tweet @pouchdb!

If you think you've found a bug in PouchDB, please write a reproducible test case and file a Github issue. You can start with a template we have built on glitch.

Prerelease builds

If you like to live on the bleeding edge, you can build PouchDB from source using these steps:

git clone https://github.com/pouchdb/pouchdb.git
cd pouchdb
npm install

After running these steps, the browser build can be found in packages/node_modules/pouchdb/dist/pouchdb.js.

Changelog

PouchDB follows semantic versioning. To see a changelog with all PouchDB releases, check out the Github releases page.

For a concise list of breaking changes, there's the wiki list of breaking changes.

Keep in mind that PouchDB is auto-migrating, so a database created in 1.0.0 will still work if you open it in 4.0.0+. Any release containing a migration is clearly marked in the release notes.

Contributing

We're always looking for new contributors! If you'd like to try your hand at writing code, writing documentation, designing the website, writing a blog post, or answering questions on StackOverflow, then we'd love to have your input.

If you have a pull request that you'd like to submit, please read the contributing guide for info on style, commit message format, and other (slightly!) nitpicky things like that. PouchDB is heavily tested, so you'll also want to check out the testing guide.

Comments
  • Feature Request - Method to Purge a document

    Feature Request - Method to Purge a document

    opened by jpgreen 115
  • IE and WinJS: Docs becoming corrupted after startup when syncing with CouchDB

    IE and WinJS: Docs becoming corrupted after startup when syncing with CouchDB

    I'm currently developing a WinJS app and, as usual during the development cycle, I'm restarting the whole thing quite often. This sometimes results in a partial corruption of the database. Basically, it looks like the delimiter between the fields isn't recognized or converted into something that isn't recognized. Which results in some fields being pulled into the _id field. Basically looks like this in Futon:

    image

    It's the three rows in the middle - take row 5, for example. That one had an _id of "chemie" and a field named "Chemie". Now both are in the id and when I try to select it, I get an Error: The selected document could not be retrieved.

    I can retrieve the document in PouchDB, however. When I try to do so I can also see that it dropped the field named "type" - simply isn't there anymore.

    I'm a bit unsure on how to replicate this behaviour, though.

    Trying to delete it programmatically with the id yielded by javascript inside Pouchdb only results in the following error:

    {"status":404,"name":"not_found","message":"missing"}
    

    But if I'm using the id displayed in Futon (the one with what I guess are UTF-8 char codes?) then I can actually delete them. And the deletion is synced to CouchDB.

    Oh, one addendum: The fact that you're seeing the proper document with the id of "chemie" on my screenshot is just due to the fact that my program is searching for seed entries in the db - and if those don't exist then they're created. It does not mean that CouchDB or PouchDB creates duplicates which then become corrupted.

    opened by Rhywden 70
  • Can't create databases in iOS 10 on Safari or Chrome

    Can't create databases in iOS 10 on Safari or Chrome

    Issue

    Can't create PouchDB on iOS10 Safari or Chrome

    Info

    • Environment: (Browser)
    • Platform: (iOS - Chrome 63.0.3239.73 and Safari)
    • Adapter: (IndexedDB (letting PouchDB choose))
    • PouchDB Version: 6.4.2

    Reproduce

    1. Have a page that includes PouchDB 6.4.2
    2. Add some code to create a database
    3. Hit the page from an iOS 10 device in Safari or Chrome

    Expected Result

    The database should be created using the IndexedDB adapter.

    Actual Result

    The database is not created and the following error is logged:

    Database has a global failure message: An unknown error occurred within Indexed Database name: UnknownError

    Failed to open indexedDB, are you in private browsing mode?

    objectStore@[native code] [email protected]:7:83327 [email protected]:7:89900 [email protected]:7:89906

    Test Case

    https://attractive-brand.glitch.me/

    opened by rdwoodring 69
  • (#1734) - WIP - simultaneous writes

    (#1734) - WIP - simultaneous writes

    Sadly this test fails in Node. Without transactions, I'm guessing the only solution is task queues, which will unfortunately not work unless we tie them to db names rather than PouchDB instances.

    it('handles simultaneous writes', function (done) {
      var db = new PouchDB(dbs.name);
      var id = 'fooId';
      var errorNames = [];
      var ids = [];
      var numDone = 0;
      function callback(err, res) {
        should.not.exist(err);
        if (res[0].error) {
          errorNames.push(res[0].name);
        } else {
          ids.push(res[0].id);
        }
        console.log(res);
        if (++numDone === 2) {
          errorNames.should.deep.equal(['conflict']);
          ids.should.deep.equal([id]);
          done();
        }
      }
      db.bulkDocs({docs : [{_id : id}]}, callback);
      db.bulkDocs({docs : [{_id : id}]}, callback);
    });
    
    opened by nolanlawson 65
  • PouchDB no longer syncs with Sync Gateway

    PouchDB no longer syncs with Sync Gateway

    I had this working for a while, and it was working fine, but at some point it stopped working. I can't tell exactly with which version it happened, but it surely isn't working now. My application works fine with CouchDB, but I need Sync Gateway to prevent different groups from seeing each others data.

    While trying to figure out why it no longer works, I noticed that - if I'm using sync gateway - I get an error like the one below, copied from the Chrome debugger:

    Request URL:http://localhost:4000/sync/781EDD37-6ACB-4AAF-A2D9-A78FD02B5D21?revs=true&open_revs=[%222-82e1bd18fc21555cc778a9a2253cb78f%22]&attachments=true&_nonce=JIBQ0zcggauTPdth Request Method:GET Status Code:406 Not Acceptable Accept:application/json Accept-Encoding:gzip,deflate,sdch Accept-Language:en-US,en;q=0.8,nl;q=0.6 Cache-Control:no-cache Connection:keep-alive Content-Type:application/json Cookie:SyncGatewaySession=d45dfff6ba61d5c36ae3a0101929e5dafa212e9e Host:localhost:4000 Pragma:no-cache Referer:http://localhost:4000/ User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36 Query String Parametersview sourceview URL encoded revs:true open_revs:["2-82e1bd18fc21555cc778a9a2253cb78f"] attachments:true _nonce:JIBQ0zcggauTPdth

    Response Connection:keep-alive Content-Length:59 Content-Type:application/json Date:Mon, 17 Mar 2014 08:48:25 GMT Server:nginx/1.0.2 {"error":"Not Acceptable","reason":"Response is multipart"}

    I'm using the latest version of PouchDB (on master) and tried both with beta2 and beta3 of Couchbase's Sync Gateway.

    opened by wspringer 65
  • (#1172) Fix total_rows/migration for websql/idb/ldb

    (#1172) Fix total_rows/migration for websql/idb/ldb

    This commit adds several major fixes to the WebSQL and IDB adapters:

    1. total_rows now correctly returns the number of undeleted documents, ala Couch.

    2. keys/startkey/endkey/key/limit/offset logic is now largely handled in the database for performance (esp. WebSQL).

    3. Various fixes to the above to match Couch behavior.

    4. Migration logic to ensure that even if the database schema changes, existing users can be migrated to the new schema. Migrations have unit tests.

    opened by nolanlawson 65
  • WIP - change batching for replication

    WIP - change batching for replication

    I still can't get a clean test run for this in node (haven't tried the browser yet). It is close to what I had intended, but I'm stymied by a surprising number of leveldb bugs. I'm taking a break now, but thought you might like to consider this.

    With all the interference, I have lost track a bit, but I believe this puts bounds on memory for both changes and replicate (i.e. it should work even for very large changes feeds). It throttles changes to limit the queue of replicate batches. It signals uptodate, but a bit prematurely. The event should be deferred until the documents are written. I know what I want to do about this, but must get back to other work now.

    There is a new option for replication: opts.batchs_limit, which is an upper bound on the number of batches queued.

    The algorithm is somewhat as Dale and Calvin have discussed, but different in some details.

    npm test was running fairly reliably with batch_size = batches_limit = 1 (after fixing a few bugs elsewhere), but is not yet clean with batch_size = batches_limit = 100.

    The latest problem appears to be a fault in allDocs on leveldb (#1961). It it can't be sorted soon I'll remove the revision-1 stuff pending a fix, to get this going and stable.

    It may be just my bad luck, but at the moment I am feeling there may be a bit too much change and too little testing going on. It sure seems easy for me to find bugs... Anyway, time for a nap and I'll look at it with fresh eyes later.

    Comments and suggestions welcome.

    opened by ig3 64
  • destroy() race condition causing IndexedDB to hang

    destroy() race condition causing IndexedDB to hang

    Still haven't tracked this down, but opening up an issue so it doesn't fall through the cracks.

    I've managed to get IndexedDB in a state where it just doesn't respond in Chrome after a few tests. Seems to be related to stale: update_after in map/reduce causing some parallelism. Weirdly, the tests complete when the Dev Tools are open, so we may have another Heiseinbug on our hands.

    https://github.com/pouchdb/pouchdb/pull/3414 does not fix this particular bug.

    bug 
    opened by nolanlawson 60
  • iOS 7.1.x Safari: Maximum call stack exceeded when performing replicate.from() using remote CouchDB

    iOS 7.1.x Safari: Maximum call stack exceeded when performing replicate.from() using remote CouchDB

    I first brought this issue up in the message group: https://groups.google.com/forum/#!topic/pouchdb/pLvogMtICZI

    Replicating a relatively small DB with a few conflicts errors out only on iOS Safari. All other OS and browser combinations appear to be unaffected.

    There is a live Mocha + Chai test available at: https://batmobile.caltech.edu:8080/db_test

    Test output:
        Database
            . Should create a session 215ms
            . Should destroy old DB 247ms
            . Should create new DB
            X Should sync the remote DB
                Error: RangeError: Maximum call stack size exceeded. (https://batmobile.caltech.edu:8080/js/vendor/pouchdb-2.2.3.js:5284)
    
    [Error stack]
        (anonymous function) (db_test, line 122)
        emit (pouchdb.js, line 7196)
        completeReplication (pouchdb.js, line 5898)
        abortReplication (pouchdb.js, line 5874)
        (anonymous function) (pouchdb.js, line 5828)
        (anonymous function) (pouchdb.js, line 7770)
        drainQueue (pouchdb.js, line 7801)
    
    PouchError
    line: 5695
    message: "the statement callback raised an exception or statement error callback did not return false"
    name: "Object"
    result: {
        doc_write_failures: 2
        docs_read: 298
        docs_written: 296
        end_time: Mon Jul 28 2014 13:36:18 GMT-0700 (PDT)
        errors: Array[0]
        last_seq: 283
        ok: false
        start_time: Mon Jul 28 2014 13:34:44 GMT-0700 (PDT)
        status: "aborted"
        __proto__: Object
    }
    sourceURL: "https://batmobile.caltech.edu:8080/js/vendor/pouchdb.js"
    stack: "https://batmobile.caltech.edu:8080/js/vendor/pouchdb.js:5695:16↵https://batmobile.caltech.edu:8080/js/vendor/pouchdb.js:7770:25↵drainQueue@https://batmobile.caltech.edu:8080/js/vendor/pouchdb.js:7801:18"
    
    CouchDB info:
        Version: 1.5.0
        Size: 2.8 MB
        # Documents: 180
        Update Seq: 3751
    
    Last requests to CouchDB:
        CouchDB proxy: /vdn_qunit/_local/e81a403483bed6460db04b698e2a0fdd?_nonce=wBXbOqWPlbrVxDpH
        CouchDB proxy: /vdn_qunit/_local/e81a403483bed6460db04b698e2a0fdd
        CouchDB proxy: /vdn_qunit/_changes?timeout=25000&style=all_docs&since=283&limit=1&_nonce=CSVWsPPCfbQmHYFX
        CouchDB proxy: /vdn_qunit/_changes?timeout=25000&style=all_docs&since=284&limit=1&_nonce=akRq9y9CbTnmO8at
        CouchDB proxy: /vdn_qunit/_all_docs?include_docs=true&keys=%5B%5D&_nonce=x7PDL4EDMNGPSRpT
        CouchDB proxy: /vdn_qunit/version_record?revs=true&open_revs=[%221015-2c43abc312a1fa3111471c1582f04498%22,%22400-a99217242854ec5b7e537f76a1bdc1b9%22]&attachments=true&_nonce=yH5y4TpjVgb2THC2
    
    opened by smeinel 60
  • RFC: Breaking changes in 6.0.0 (discussion)

    RFC: Breaking changes in 6.0.0 (discussion)

    If we're going to do a breaking change, let's cram as many breakages in as we can.

    Slated:

    • Remove new PouchDB().then() (https://github.com/pouchdb/pouchdb/pull/5319)
    • Remove db.put(doc, id, rev) (https://github.com/pouchdb/pouchdb/pull/5311)
    • extras API

    Others we want to sneak in? Now would be the time. (Edit this comment to add more!)

    opened by nolanlawson 57
  • Get tests passing against cloudant

    Get tests passing against cloudant

    As title

    I believe the different checkpoint used by bigcouch is to be considered opaque and in both implementation of plain couchdb and bigcouch we should just be sending transferring the token without assuming a type


    Want to back this issue? Place a bounty on it! We accept bounties via Bountysource.

    enhancement 
    opened by daleharvey 52
  • Translate partial filter selectors into indexed db indexes

    Translate partial filter selectors into indexed db indexes

    Issue

    With the merging of #8523 mango indexes with partial_filter_selectors use the MapReduce Views on the indexeddb-adapter. While this works, it reduces the performance, doesn't auto-update (by the browser), and has a different ordering.

    This issue is to find a way to use native IndexedDB indexes for Mango Indexes with partial_filter_selectors.

    There are two paths:

    • Translate partial_filter_selectors into indexes.
    • Or lobby for support of partial indexes for IndexedDB indexes to the W3C (SQL has them two, after all). This issue would then be use-case for it.

    Basic Translation

    The easiest to translate are the Implicit Operators $and and $eq (in their implicit and explicit forms).

    The following index:

    {
      "index": {
        "fields": ["title"],
        "partial_filter_selector": {
          "type": { "$eq": "story" }
        }
      }
    }
    

    could be translated into:

    {
      "index": {
        "fields": ["type", "title"]
      }
    }
    

    And on querying the index PouchDB would then add the "type": { "$eq": "story" } to the query-selector, if it is missing.

    The (In)equality operators ($lt, $lte, $eq, $gte, and $gt) could also be translated into the index. So would the partial_filter_selector example for the PouchDB API docs translated to:

    {
      "index": {
        "fields": ["year", "title"]
      }
    }
    

    and year: { $gt: 2010 } be added to the query-selector.

    $or Operator

    Support for the $or Operator and alike are already more complicated, but doable. They could be translated into an index just like $and would, but while fetching PouchDB would fetch each selector in the or-array and merge and sort the results.

    Rest

    As a fall back for all selector which can't be translated into indexes, PouchDB should try the closest matching indexes. Query it, filter then the results. And continue this until the limit is reached. This should(?) be faster then using the default _id index.


    Is this feasible? Any ideas?

    opened by Terreii 0
  • debug_mode missing from documentation

    debug_mode missing from documentation

    Issue

    debug mode is listed on the index of the API page, but there is nothing in the contents

    Info

    www.pouchdb.com

    Reproduce

    Browse to https://pouchdb.com/api.html#debug_mode

    opened by baradhili 0
  • pouchdb-authentication, getSession() with different domain shows null

    pouchdb-authentication, getSession() with different domain shows null

    Issue

    I'm using pouchdb-authentication plugin to handle my couchdb authentication. The issue is when I try to login a valid user with different domains like front end domain: http://localhost:8080/login and backend domain: http://127.0.0.1:5984/mydb/ my getSession() function returns a null userCxt name: userCtx: {name: null, roles: []}. however when I try to login same user with same domains like front end domain: http://localhost:8080/login and backend domain: http://localhost:5984/mydb/ my getSession() function returns the user userCxt name: userCtx: {name:"testUser", roles: []}.

    Info

    • Environment: browser
    • Platform: Chrome
    • Adapter: none
    • Server: CouchDB

    Reproduce

    To reproduce the issue:

    • create a login form running on a domain different from the couchdb domain
    • create the poucdb instance with http://127.0.0.1:5984/mydb/ or some other remote couchdb
    • authenticate the user with pouchdb-authentication login function
    • get the user session with pouchdb-authentcation getSession() function
    opened by faisalabdulkadir 0
  • The error `this.emit is not a function` has been raised while local storage has changed from other windows.

    The error `this.emit is not a function` has been raised while local storage has changed from other windows.

    Issue

    Hi, team! I am always thankful to you for this grateful and excellent database!

    I noticed that the error that I wrote in the title became shown on the browser. (It happens both with using pouchdb-browser and custom build from the core and some required plugins.). After I checked some behaviour and realise a concern, therefore I made a patch. The reference to this looks has been captured in the function at packages/node_modules/pouchdb-utils/src/changesHandler.js.

    I made the patch and tested it, and looks like works fine.

    Would you mind if I make make a pull request?

    Info

    • Environment: Browser
    • Platform: Chrome
    • Adapter: idb
    • Server: N/A

    Reproduce

    1. Open two windows of pouchdb.com
    2. Open devTools in both windows. perform localStorage.setItem("Hello", World")
    3. The error appears in the opposite window.
    opened by vrtmrz 3
Releases(8.0.0)
Owner
PouchDB
The database that syncs!
PouchDB
DolphinDB JavaScript API is a JavaScript library that encapsulates the ability to operate the DolphinDB database, such as: connecting to the database, executing scripts, calling functions, uploading variables, etc.

DolphinDB JavaScript API English | 中文 Overview DolphinDB JavaScript API is a JavaScript library that encapsulates the ability to operate the DolphinDB

DolphinDB 6 Dec 12, 2022
🔄 A realtime Database for JavaScript Applications

RxDB A realtime Database for JavaScript Applications RxDB (short for Reactive Database) is a NoSQL-database for JavaScript Applications like Websites,

Daniel Meyer 18.6k Dec 31, 2022
⚡️ lowdb is a small local JSON database powered by Lodash (supports Node, Electron and the browser)

Lowdb Small JSON database for Node, Electron and the browser. Powered by Lodash. ⚡ db.get('posts') .push({ id: 1, title: 'lowdb is awesome'}) .wri

null 18.9k Dec 30, 2022
Execute one command (or mount one Node.js middleware) and get an instant high-performance GraphQL API for your PostgreSQL database!

PostGraphile Instant lightning-fast GraphQL API backed primarily by your PostgreSQL database. Highly customisable and extensible thanks to incredibly

Graphile 11.7k Jan 4, 2023
🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️

A reactive database framework Build powerful React and React Native apps that scale from hundreds to tens of thousands of records and remain fast ⚡️ W

Nozbe 8.8k Jan 5, 2023
Lovefield is a relational database for web apps. Written in JavaScript, works cross-browser. Provides SQL-like APIs that are fast, safe, and easy to use.

Lovefield Lovefield is a relational database written in pure JavaScript. It provides SQL-like syntax and works cross-browser (currently supporting Chr

Google 6.8k Jan 3, 2023
AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.

Please use version 1.x as prior versions has a security flaw if you use user generated data to concat your SQL strings instead of providing them as a

Andrey Gershun 6.1k Jan 9, 2023
Realm is a mobile database: an alternative to SQLite & key-value stores

Realm is a mobile database that runs directly inside phones, tablets or wearables. This project hosts the JavaScript versions of Realm. Currently we s

Realm 5.1k Jan 3, 2023
:rocket: One command to generate REST APIs for any MySql Database.

Xmysql : One command to generate REST APIs for any MySql database Why this ? Generating REST APIs for a MySql database which does not follow conventio

null 129 Dec 30, 2022
Realtime database backend based on Operational Transformation (OT)

This README is for [email protected]. For [email protected], see the 1.x-beta branch. To upgrade, see the upgrade guide. ShareDB ShareDB is a realtime databa

ShareJS 5.5k Dec 29, 2022
A transparent, in-memory, streaming write-on-update JavaScript database for Small Web applications that persists to a JavaScript transaction log.

JavaScript Database (JSDB) A zero-dependency, transparent, in-memory, streaming write-on-update JavaScript database for the Small Web that persists to

Small Technology Foundation 237 Nov 13, 2022
The JavaScript Database, for Node.js, nw.js, electron and the browser

The JavaScript Database Embedded persistent or in memory database for Node.js, nw.js, Electron and browsers, 100% JavaScript, no binary dependency. AP

Louis Chatriot 13.2k Jan 2, 2023
Bluzelle is a smart, in-memory data store. It can be used as a cache or as a database.

SwarmDB ABOUT SWARMDB Bluzelle brings together the sharing economy and token economy. Bluzelle enables people to rent out their computer storage space

Bluzelle 225 Dec 31, 2022
The ultimate solution for populating your MongoDB database.

Mongo Seeding The ultimate solution for populating your MongoDB database ?? Define MongoDB documents in JSON, JavaScript or even TypeScript files. Use

Paweł Kosiec 494 Dec 29, 2022
Node.js client for the Aerospike database

Aerospike Node.js Client An Aerospike add-on module for Node.js. The client is compatible with Node.js v8.x, v10.x (LTS), v12.x (LTS), and v14.x (LTS)

Aerospike 198 Dec 30, 2022
Common Database Interface for Node

database-js Wrapper for multiple databases with a JDBC-like connection Database-js implements a common, promise-based interface for SQL database acces

null 57 Dec 3, 2022
NodeJS PostgreSQL database performance insights. Locks, index usage, buffer cache hit ratios, vacuum stats and more.

Node Postgres Extras NodeJS port of Heroku PG Extras with several additions and improvements. The goal of this project is to provide powerful insights

Paweł Urbanek 68 Nov 14, 2022
A MongoDB-like database built on top of Hyperbee with support for indexing

hyperbeedeebee A MongoDB-like database built on top of Hyperbee with support for indexing WIP: There may be breaking changes in the indexing before th

null 35 Dec 12, 2022
Google Sheets as a Database - Next.js Demo

Google Sheets as a Database Use Google Sheets as a primary database for your Next.js project. Watch on YouTube or follow allong with the full Google S

Fireship 45 Dec 8, 2022