# pouchdb-rewrite

> A PouchDB plug-in that allows you to re-use your CouchDB rewrites on the client side.

Latest version **4.2.0** (published 2019-09-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install pouchdb-rewrite
pnpm add pouchdb-rewrite
yarn add pouchdb-rewrite
bun add pouchdb-rewrite
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.2.0 |
| Published | 2019-09-25 |
| First published | 2014-06-05 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 84.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 979 |
| Author | Marten de Vries |
| Maintainers | commandoline, daleharvey, garrensmith, nolanlawson |
| Keywords | pouch, pouchdb, couch, couchdb, rewrite, design |

## Links

- npm: https://www.npmjs.com/package/pouchdb-rewrite
- Repository: https://github.com/pouchdb/pouchdb-server
- Homepage: https://github.com/pouchdb/pouchdb-server#readme
- Issues: https://github.com/pouchdb/pouchdb-server/issues
- npm.io page: https://npm.io/package/pouchdb-rewrite

## Dependencies (6)

- [extend](https://npm.io/package/extend.md) ^3.0.0
- [pouchdb-route](https://npm.io/package/pouchdb-route.md) 4.2.0
- [promise-nodify](https://npm.io/package/promise-nodify.md) ^1.0.2
- [couchdb-objects](https://npm.io/package/couchdb-objects.md) 4.2.0
- [pouchdb-plugin-error](https://npm.io/package/pouchdb-plugin-error.md) 4.2.0
- [pouchdb-req-http-query](https://npm.io/package/pouchdb-req-http-query.md) 4.2.0

## Recent versions

- 4.2.0 (latest) — 2019-09-25
- 5.0.1-rc1.0 (beta) — 2025-08-27
- 4.1.0 — 2018-08-13
- 4.0.1 — 2018-06-05
- 4.0.0 — 2018-01-27
- 1.0.7 — 2016-02-05
- 1.0.6 — 2015-08-19
- 1.0.5 — 2015-01-09
- 1.0.4 — 2014-09-01
- 1.0.3 — 2014-07-06
- 1.0.2 — 2014-07-04
- 1.0.1 — 2014-06-05
- 1.0.0 — 2014-06-05
- 0.1.0 — 2014-06-05

## README

pouchdb-rewrite
===============

A PouchDB plug-in that allows you to re-use your CouchDB rewrites on the
client side. A browser version is available.

API
---

**NodeJS package name:** `pouchdb-rewrite`

**Browser object name:** `window.Rewrite`

First, make sure you understand CouchDB rewrites. A good starting point
is [the rewrite documentation](http://docs.couchdb.org/en/latest/api/ddoc/rewrites.html).

### Rewrite.rewrite(rewritePath[, options[, callback]])

Figures out where to redirect to, and then executes the corresponding
PouchDB function, with the appropriate arguments gotten from the
request object that has been generated from the `options`
parameter.

`rewritePath`: a path of the form `"designDocName/rewrite/path"`. Specifies
the design document to use the rewrites from, and the path you'd find in
CouchDB after the `/_rewrite` part of the URL. Keep in mind that you can't
specify a query parameter in the url form (i.e. no `?a=b`). Instead use the
`options.query` parameter.

`options`: A CouchDB request object stub. Important properties of those for
rewrites are `options.query` and `options.method`. An additional boolean option
is available: `options.withValidation`, if true, this function routes to
`db.validating*` functions instead of `db.*` functions if relevant.

**Returns**: whatever output the function that the rewrite routed to produced.
Or, in the case of an 'http' database, a CouchDB response object.

### Rewrite.rewriteResultRequestObject(rewritePath[, options[, callback]])

See the `Rewrite.rewrite` function for information on the parameters.
The difference with it is that this function doesn't try to route the rewrite
to a function.

**Returns**: A CouchDB request object that points to the resource obtained by
following the redirect.

Source
------

PouchDB Server and its sub-packages are distributed as a [monorepo](https://github.com/babel/babel/blob/master/doc/design/monorepo.md).

For a full list of packages, see [the GitHub source](https://github.com/pouchdb/pouchdb-server/tree/master/packages/node_modules).

License
-------

The Apache 2 License. See [the LICENSE file](https://github.com/pouchdb/pouchdb-server/blob/master/LICENSE) for more information.

---
_Source: https://npm.io/package/pouchdb-rewrite · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
