Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Write the description of the issue here
### Info
- Environment: (Node.js/browser/hybrid app/etc.)
- Platform: (Chrome/FF/Safari/Edge/iOS/Android/etc.)
- Adapter: (idb/indexeddb/memory/leveldb/etc.)
- Adapter: (idb/indexeddb/nodesqlite/etc.)
- Server: (CouchDB/Cloudant/PouchDB Server/etc.)

### Reproduce
Expand Down
113 changes: 55 additions & 58 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
fail-fast: false
matrix:
couchdb: ['2.3', '3.1']
node: [20, 22]
node: [22]
cmd:
- npm test
- TYPE=find PLUGINS=pouchdb-find ADAPTERS=http npm test
Expand Down Expand Up @@ -158,60 +158,6 @@ jobs:
if: steps.retry.outcome == 'failure'
run: ${{ matrix.cmd }}

# Run the integration, find and mapreduce tests against all the Node.js
# PouchDB adapters. This should be run for every adapter on every version of
# Node.js we support.

nodejs-adapter:
needs: lint
strategy:
fail-fast: false
matrix:
node: [20, 22]
adapter: ['leveldb', 'memory']
cmd:
- npm test
- TYPE=find PLUGINS=pouchdb-find npm test
- TYPE=mapreduce npm test
runs-on: ubuntu-latest
services:
couchdb:
image: couchdb:3.1
ports:
- 5984:5984
env:
COUCHDB_USER: admin
COUCHDB_PASSWORD: password
env:
CLIENT: node
SERVER: couchdb-master
COUCH_HOST: http://admin:password@127.0.0.1:5984
SKIP_MIGRATION: 1
ADAPTERS: ${{ matrix.adapter }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Wait for CouchDB
run: ./bin/wait-for-couch.sh 20
- name: Setup CouchDB CORS
run: curl 'http://admin:password@127.0.0.1:5984/_node/_local/_config/cors/origins' -X PUT -d '"http://127.0.0.1:8000"'
- uses: ./.github/actions/install-node-package
with:
node-version: ${{ matrix.node }}
- uses: ./.github/actions/build-pouchdb
- id: test
run: ${{ matrix.cmd }}
continue-on-error: true
- name: First retry
id: retry
if: steps.test.outcome == 'failure'
run: ${{ matrix.cmd }}
continue-on-error: true
- name: Second retry
if: steps.retry.outcome == 'failure'
run: ${{ matrix.cmd }}

# Run the integration, find and mapreduce tests against all the browser-based
# adapters. PouchDB adapters. This should be run for every adapter on every
# target browser.
Expand All @@ -222,7 +168,7 @@ jobs:
fail-fast: false
matrix:
client: ['firefox', 'chromium', 'webkit']
adapter: ['idb', 'indexeddb', 'memory']
adapter: ['idb', 'indexeddb']
cmd:
- npm test
- TYPE=find PLUGINS=pouchdb-find npm test
Expand Down Expand Up @@ -275,7 +221,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [20, 22]
node: [22]
cmd:
- CLIENT=firefox npm run test-webpack
- AUTO_COMPACTION=true npm test
Expand Down Expand Up @@ -324,7 +270,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [20, 22]
node: [22]
cmd:
- TYPE=performance npm test
runs-on: ubuntu-latest
Expand All @@ -347,3 +293,54 @@ jobs:
- name: Second retry
if: steps.retry.outcome == 'failure'
run: git reset --hard && ${{ matrix.cmd }}

nodejs-sqlite-adapter:
needs: lint
strategy:
fail-fast: false
matrix:
node: [22]
adapter: ['nodesqlite']
cmd:
- npm test
- TYPE=find PLUGINS=pouchdb-find npm test
- TYPE=mapreduce npm test
runs-on: ubuntu-latest
services:
couchdb:
image: couchdb:3.1
ports:
- 5984:5984
env:
COUCHDB_USER: admin
COUCHDB_PASSWORD: password
env:
CLIENT: node
SERVER: couchdb-master
COUCH_HOST: http://admin:password@127.0.0.1:5984
SKIP_MIGRATION: 1
ADAPTERS: ${{ matrix.adapter }}
VIEW_ADAPTERS: nodesqlite
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Wait for CouchDB
run: ./bin/wait-for-couch.sh 20
- name: Setup CouchDB CORS
run: curl 'http://admin:password@127.0.0.1:5984/_node/_local/_config/cors/origins' -X PUT -d '"http://127.0.0.1:8000"'
- uses: ./.github/actions/install-node-package
with:
node-version: ${{ matrix.node }}
- uses: ./.github/actions/build-pouchdb
- id: test
run: ${{ matrix.cmd }}
continue-on-error: true
- name: First retry
id: retry
if: steps.test.outcome == 'failure'
run: ${{ matrix.cmd }}
continue-on-error: true
- name: Second retry
if: steps.retry.outcome == 'failure'
run: ${{ matrix.cmd }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ yarn.lock
release-todo.txt
/perf-test-results/
/dist-bundles/
*.sqlite
17 changes: 8 additions & 9 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ The main test suite can be run using the following command:
> If the tests don‘t pass on `main`, try building once before running the tests: `$npm run build`.

PouchDB runs in the browser and on Node.js, and has multiple different storage
backends known as _adapters_. In the browser these are `idb`, `indexeddb` and
`memory` and on Node.js they're `leveldb` and `memory`.
backends known as _adapters_. In the browser these are `idb` and `indexeddb` and on Node.js there is `nodesqlite`.

It also includes an adapter named `http`, which works by delegating operations
to CouchDB (or anything that's API-compatible with it) over the network. Since
Expand All @@ -92,8 +91,8 @@ databases. These are selected automatically based on the execution environment,
but this variable overrides the default choice and causes additional adapters to
be loaded if they're not part of the default distribution.

On Node.js the available local adapters are `leveldb` and `memory`. In the
browser they're `idb`, `indexeddb` and `memory`.
On Node.js the available local adapter is `nodesqlite`. In the
browser they're `idb` and `indexeddb`.

You can also set `ADAPTERS=http` to force all PouchDB databases to be created on
a remote server, identified by `COUCH_HOST`. This is not necessary for
Expand Down Expand Up @@ -181,14 +180,14 @@ following values:

Set this to `1` to skip the migration tests.

#### `VIEW_ADAPTERS` (default: `memory`) <!-- omit from toc -->
#### `VIEW_ADAPTERS` (default: `nodesqlite`) <!-- omit from toc -->

Comma-separated list of preferred view adapter backends that PouchDB will use.
This variable overrides the default choice and causes additional adapters to
be loaded if they're not part of the default distribution.

On Node.js the available adapters are `leveldb` and `memory`. In the
browser they're `idb`, `indexeddb` and `memory`.
On Node.js the available adapter is `nodesqlite`. In the
browser they're `idb` and `indexeddb`.


## Other sets of tests
Expand All @@ -213,8 +212,8 @@ These suites support most of the same options as the integration tests.
You'll want to test specific adapters by specifying them on the command-line,
for example:

# run the "find" tests with the memory client on node.js
$ TYPE=find PLUGINS=pouchdb-find CLIENT=node ADAPTERS=memory npm test
# run the "find" tests with the nodesqlite client on node.js
$ TYPE=find PLUGINS=pouchdb-find CLIENT=node ADAPTERS=nodesqlite npm test

# run the "mapreduce" tests with indexeddb in firefox
$ TYPE=mapreduce CLIENT=firefox ADAPTERS=indexeddb npm test
Expand Down
3 changes: 1 addition & 2 deletions bin/build-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ var AGGRESSIVELY_BUNDLED_PACKAGES =
var BROWSER_ONLY_PACKAGES =
['pouchdb-browser'];
// packages that only use the browser field to ignore dependencies
var BROWSER_DEPENDENCY_ONLY_PACKAGES =
['pouchdb-adapter-leveldb'];
var BROWSER_DEPENDENCY_ONLY_PACKAGES = ['pouchdb-adapter-nodesqlite'];

function buildModule(filepath) {
var pkg = require(path.resolve(filepath, 'package.json'));
Expand Down
20 changes: 1 addition & 19 deletions bin/build-pouchdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var builtInModules = require('builtin-modules');
var external = Object.keys(require('../package.json').dependencies)
.concat(builtInModules);

var plugins = ['indexeddb', 'localstorage', 'memory', 'find'];
var plugins = ['indexeddb', 'find'];

var currentYear = new Date().getFullYear();

Expand All @@ -42,24 +42,6 @@ var comments = {

'indexeddb': '// PouchDB indexeddb plugin ' + version + '\n',

'memory': '// PouchDB in-memory plugin ' + version +
'\n// Based on MemDOWN: https://github.com/rvagg/memdown' +
'\n// ' +
'\n// (c) 2012-' + currentYear + ' Dale Harvey and the PouchDB team' +
'\n// PouchDB may be freely distributed under the Apache license, ' +
'version 2.0.' +
'\n// For all details and documentation:' +
'\n// http://pouchdb.com\n',

'localstorage': '// PouchDB localStorage plugin ' + version +
'\n// Based on localstorage-down: https://github.com/No9/localstorage-down' +
'\n// ' +
'\n// (c) 2012-' + currentYear + ' Dale Harvey and the PouchDB team' +
'\n// PouchDB may be freely distributed under the Apache license, ' +
'version 2.0.' +
'\n// For all details and documentation:' +
'\n// http://pouchdb.com\n',

'find': '// pouchdb-find plugin ' + version +
'\n// Based on Mango: https://github.com/cloudant/mango' +
'\n// ' +
Expand Down
11 changes: 9 additions & 2 deletions bin/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ fi

: "${CLIENT:=node}"
: "${COUCH_HOST:=http://127.0.0.1:5984}"
: "${VIEW_ADAPTERS:=memory}"
export VIEW_ADAPTERS

if [ -z "$VIEW_ADAPTERS" ]; then
if [ "$CLIENT" == "node" ]; then
export VIEW_ADAPTERS="nodesqlite"
else
export VIEW_ADAPTERS="indexeddb"
fi
fi


pouchdb-setup-server() {
# in CI, link pouchdb-servers dependencies on pouchdb
Expand Down
2 changes: 0 additions & 2 deletions bin/verify-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ getReqs('pouchdb/lib/index.js').should.not.contain('pouchdb-core');
getReqs('pouchdb/lib/index-browser.js').should.not.contain('vm');
getReqs('pouchdb/lib/index-browser.js').should.not.contain('pouchdb-mapreduce');
getReqs('pouchdb/lib/index-browser.js').should.not.contain('pouchdb');
getReqs('pouchdb/lib/index-browser.js').should.not.contain('leveldown');
getReqs('pouchdb/lib/index-browser.js').should.not.contain('pouchdb-core');

// pouchdb-node and pouchdb-browser are also aggressively bundled
getReqs('pouchdb-node/lib/index.js').should.not.contain('pouchdb-core');
getReqs('pouchdb-node/lib/index.js').should.contain('leveldown');
getReqs('pouchdb-browser/lib/index.js').should.not.contain('pouchdb-core');

// pouchdb-for-coverage is super-duper aggressively bundled
Expand Down
2 changes: 1 addition & 1 deletion docs/_includes/api/batch_fetch.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* `options.startkey` &amp; `options.endkey`: Get documents with IDs in a certain range (inclusive/inclusive).
* `options.inclusive_end`: Include documents having an ID equal to the given `options.endkey`. Default: `true`.
* `options.limit`: Maximum number of documents to return.
* `options.skip`: Number of docs to skip before returning (warning: poor performance on IndexedDB/LevelDB!).
* `options.skip`: Number of docs to skip before returning (warning: poor performance on IndexedDB!).
* `options.descending`: Reverse the order of the output documents. Note that the order of `startkey` and `endkey` is reversed when `descending`:`true`.
* `options.key`: Only return documents with IDs matching this string key.
* `options.keys`: Array of string keys to fetch in a single shot.
Expand Down
7 changes: 2 additions & 5 deletions docs/_includes/api/create_database.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
**Options for local databases:**

* `auto_compaction`: This turns on auto compaction, which means `compact()` is called after every change to the database. Defaults to `false`.
* `adapter`: One of `'indexeddb'`, `'idb'`, `'leveldb'`, or `'http'`.
* `adapter`: One of `'indexeddb'`, `'idb'`, `'nodesqlite'`, or `'http'`.
* `revs_limit`: Specify how many old revisions we keep track (not a copy) of. Specifying a low value means Pouch may not be able to figure out whether a new revision received via replication is related to any it currently has which could result in a conflict. Defaults to `1000`.
* `deterministic_revs`: Use a md5 hash to create a deterministic revision number for documents. Setting it to false will mean that the revision number will be a random UUID. Defaults to true.
* `view_update_changes_batch_size`: Specify how many change records will be consumed at a time when rebuilding view indexes when the `query()` method is used. Defaults to 50.
Expand All @@ -30,12 +30,9 @@

1. In IndexedDB PouchDB will use `_pouch_` to prefix the internal database names. Do not manually create databases with the same prefix.
2. When acting as a client on Node, any other options given will be passed to [request][].
3. When using the `'leveldb'` adapter (the default on Node), any other options given will be passed to [levelup][].
4. If you are using the jwt auth handler, please use the fetch option to add the required headers and handle connected logic like token refreshes.
3. If you are using the jwt auth handler, please use the fetch option to add the required headers and handle connected logic like token refreshes.

[request]: https://github.com/mikeal/request
[levelup]: https://github.com/rvagg/node-levelup
[levelup_options]: https://github.com/rvagg/node-levelup/#options

#### Example Usage:
{% highlight "js" %}
Expand Down
2 changes: 1 addition & 1 deletion docs/_includes/api/database_information.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@

There are also some details you can use for debugging. These are unofficial and may change at any time:

* `adapter`: The name of the adapter being used (idb, leveldb, ...).
* `adapter`: The name of the adapter being used (idb, ...).
* `idb_attachment_format`: (IndexedDB) either `'base64'` or `'binary'`, depending on whether the browser [supports binary blobs](/faq.html#data_types).
* `backend_adapter`: (Node.JS) the backend *DOWN adapter being used (MemDOWN, RiakDOWN, ...).
2 changes: 1 addition & 1 deletion docs/_includes/api/defaults.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
const MyPrefixedPouch = PouchDB.defaults({
prefix: '/path/to/my/db/'
});
// db will be named '/path/to/my/db/dbname', useful for LevelDB
// db will be named '/path/to/my/db/dbname'
const myPrefixedPouch = new MyPrefixedPouch('dbname');

const HTTPPouch = PouchDB.defaults({
Expand Down
2 changes: 1 addition & 1 deletion docs/_includes/api/query_database.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* `options.startkey` &amp; `options.endkey`: Get rows with keys in a certain range (inclusive/inclusive).
* `options.inclusive_end`: Include rows having a key equal to the given `options.endkey`. Default: `true`.
* `options.limit`: Maximum number of rows to return.
* `options.skip`: Number of rows to skip before returning (warning: poor performance on IndexedDB/LevelDB!).
* `options.skip`: Number of rows to skip before returning (warning: poor performance on IndexedDB!).
* `options.descending`: Reverse the order of the output rows.
* `options.key`: Only return rows matching this key.
* `options.keys`: Array of keys to fetch in a single shot.
Expand Down
14 changes: 0 additions & 14 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,6 @@ <h4>{{ sub_title}}</h4>
</a>
</div>

<div class="col-xs-4 col-md-2">
<a
href="https://github.com/rvagg/node-levelup"
target="_blank"
rel="noopener noreferrer"
>
<img
class="icon"
src="{{ site.baseurl}}/static/img/friends/leveldb.svg"
alt="Node Levelup"
/>
</a>
</div>

<div class="col-xs-4 col-md-2">
<a
href="https://github.com/apache/pouchdb"
Expand Down
Loading
Loading