Alba Herrerías

By: Alba Herrerías
Published: 14 December 2022

We are thrilled to announce the release of PouchDB's new major version 8.0.0. For a full changelog from 7.3.1 to 8.0.0, please see the releases page or view the latest commits. Here are the highlights:

Embracing modern ES6+ JS syntax

We have started the process of moving to ES6+ syntax. We made refactors to use native JS classes instead of prototypes, deprecated some packages that implemented features that are now built in the language (inherits, argsarray), and started in packages such as pouchdb-abstract-mapreduce and pouchdb-adapter-http. We encourage you to embrace the syntax in your new contributions and, if you can, contribute to the refactoring effort.

This might mean a potentially breaking change, therefore we bump the major version. If you need to support ES5 we recommend you use a transpiler.

Add activeTasks

#8422 #8441 Analogous to the _active_tasks feature in CouchDB, PouchDB now has activeTasks. With this functionality, PouchDB is able to list all active database tasks, like database_compaction, view_indexing, or replication. PouchDB will report the progress of these tasks to the active tasks API and remove tasks as soon as they are completed or have failed.

Example usage: js let tasks = PouchDB.activeTasks.list()

Example result:

[{
  "id": "d81fea92-8ce4-42df-bb2b-89a4e67536c3",
  "name": "database_compaction",
  "created_at": "2022-02-08T15:38:45.318Z",
  "total_items": 12,
  "completed_items": 1,
  "updated_at": "2022-02-08T15:38:45.821Z"
}]

Add purge to the indexeddb adapter

#8453 Similar to CouchDB's purge, PouchDB has now purge for its indexeddb adapter.

Purge permanently removes data from the database. Normal deletion with db.remove() does not, it only marks the document as _deleted=true and creates a new revision. This behaviour ensures that deletes can be replicated across databases, and deleted documents don’t get undeleted by syncing with a database that still has this document.

db.purge() is not intended as a regular method for deleting documents, instead, it is meant as an admin function for cases where some secret was erroneously added to the database and must now be removed completely, eg. a credit card or social security number. Purge effectively puts the database in a state where the offending write never happened.

Example usage:

try {
  const result = await db.purge('mydoc', '6-3a24009a9525bde9e4bfa8a99046b00d');
  // handle result
} catch (error) {
  // handle error
}

Example result:

{
  "ok": true,
  "deletedRevs": [
    "6-3a24009a9525bde9e4bfa8a99046b00d",
    "5-df4a81cd21c75c71974d96e88a68fc2f"
  ],
  "documentWasRemovedCompletely": false
}

Improving publishing packages

#8576 Previously, if publishing packages failed part-way through, the release script halt and the remaining packages needed to be published by hand. With this improvement the script can be run again to publish the remaining packages.

Changelog

New features

  • 0680c0ac feat(core): simple active tasks implementation
  • c3fc43cc feat: use activeTasks error handling
  • 9a83c11f feat(core): activeTasks remove reason argument
  • 40dc6b37 feat(replicate): track live replications in activeTasks
  • f5b6d35e feat(core): view indexing use activeTasks API
  • d784b49a feat(replicate): replication uses activeTasks API
  • 52a52495 feat: database compaction use activeTasks API
  • ed0db363 feat(core): make activeTasks.list() return array
  • eaf9d52f feat(core): active tasks created_at/updated_at naming
  • 544eb77d feat(purge): add purge to core
  • ec1b7872 chore(purge): remove only from purge tests
  • 3445a012 feat(indexeddb): proof-of-concept purge method
  • e861d00f wip(indexeddb): stub _purgeRev method
  • 972ae331 wip(merge): findPathToLeaf, removeLeafFromTree
  • 4e921ebd feat(merge): removeLeafFromTree return empty trees
  • 3e3f7613 feat: make purge delete docs if tree is empty
  • a8b5e00c feat(indexeddb): attachment purging
  • 693ea5c1 feat(purge): handle missing doc, return something
  • 774976a0 feat: on-update view purging
  • 94ec8932 feat(core): purged_infos_limit support
  • ce8f8b30 [wip] Purge leaves from multiple roots
  • 4252a0f0 docs(purge): show result object seperately
  • b856173b chore(purge): add code comments
  • d5f4250a chore(purge): remove unneeded logs and comments
  • 2c0ddbb0 feat(purge): simplify implementation of removeLeafFromTree()

Bugfixes

  • 34a79749 fix: check replication currentBatch
  • 8f33ff0a fix: add activeTask stub to mock replication database
  • 3fe71b03 (#8491) - Fix $regex and $ne within $or operator
  • 86ccf481 fix(core): active tasks object datastructure
  • 5f61b1fe fix partial filter find on indexeddb adapter
  • 759ea5a0 fix: store partial_filter_selector in ddocs
  • 9519c748 fix: active tasks race condition
  • 25a12e11 fix(merge): removeLeafFromTree to properly use branchings
  • d5f29f7b fix(indexeddb): rev purging typo
  • f0958b50 fix(purge): use callback in adapter
  • b20139e1 fix(core): purge error values
  • 4d11ef51 fix(a-m-r): purge check return value
  • 203ae670 fix: remove logging
  • 24157fcf (#8513) - Race condition for pouchdb hanging indefinitely when multiple instances are used
  • 15092e8e chore: catch selenium errors earlier
  • 2eca392b fix: (#8471) filterInclusiveStart for nested fields
  • 45dc5ae8 Fix the implementation of _bulkDocs() in the http adapter without using adapterFun()
  • fcb71db4 fix: active task total items calculation (#8508)
  • 76d35e44 fix: replication cancellation race condition (#8507)

Documentation

  • 7c6753a6 Mark a few words in the 7.3 post as code so that markdown does not italicise them
  • 486076d2 Fix formatting of 7.3 release post by adding blank lines
  • c6719367 Add new author in the docs
  • 9cc72318 Add 7.3.0 release post
  • 140896cb feat: update site version to 7.3.0
  • d9c19182 docs: update PouchDB on page
  • 2afc29f7 docs: release script note
  • 861003ad docs: clarify release process
  • 47cb987c Add 7.3.1 release post
  • f00d1193 feat: update site version to 7.3.1
  • 0140bfa5 docs: active tasks API
  • 2de982e5 add performance warning for indexeddb
  • 5faa060c docs(purge): add first draft of purge docs
  • 3cfb4af4 docs(purge): update docs
  • d1c04dd5 Update attachments.md : outdated external link
  • 0200eea4 Update 2022-04-13-pouchdb-7.3.0.md

Testing

  • a3bf8ff0 test(#8522): add failing test for partial index
  • 69ce67ad chore(core): lint activetasks code and tests
  • 5fd15227 test(purge): unit tests for findPathToLeaf util
  • 621cf0a1 wip: multi-root tree purge tests
  • f28b4ad5 [wip] failing test showing bug in tracking node position in removeLeafFromTree()
  • 868937d8 tests(purge): fix tests for fixed multi-root removals
  • 63026167 chore(purge): lint
  • 8e83728b perf-tests: make wording clearer for multiple adapters
  • 34a8cf52 (#8568) - use eslint cache
  • 2b9b7fac fix(tests): reformat tree fixtures
  • 581c1048 feat(tests): purge integration tests
  • df77ecbf refactor a test that timeout to use async
  • 404346bb chore: upgrade webpack for testing

Dependency updates

  • 50d2c33a Remove inherits package dependency
  • 4974b64a refactor: remove argsarray dependency

Refactor

  • 7350a701 refactor: use es6 classes
  • 08e46002 refactor: deprecate inherits in pouchdb-core
  • 99ebea32 refactor: use class in sublevel-pouchdb
  • d4ff99b4 refactor: use classes instead of prototypes
  • 21d7975c feat(core): refactor ActiveTasks with ES6 classes
  • 07d055ae refactor: use rest parameters in find utils
  • d02eaaf0 refactor: remove argsarray usage
  • 701f96dc refactor: use await in abstract-mapreduce
  • 74a6d6fd refactor: remove unnecessary async
  • 73e0199c refactor: use ES6 syntax in http adapter
  • 133978fe refactor: use ES6 syntax in abstract-mapreduce
  • 27128d6d chore: remove obsolete replication revision-one optimization (#8499)

Other changes

  • 8e08a14c chore: delete stale bot
  • 55c2743e (#8571) - set executable mode on scripts
  • fec3c163 Make bin/publish-packages.sh exit with non-zero status on failure
  • 5b07d18d Recover if publishing packages fails part-way through

Get in touch

As always, we welcome feedback from the community and would love to hear what you think of this release as well as PouchDB's future direction. Please don't hesitate to file issues, open discussions or get in touch. And of course, a big thanks to all of our new and existing contributors!