https://github.com/jamen/pull-couchdb
Pull-streams for reading and writing in CouchDB.
https://github.com/jamen/pull-couchdb
Last synced: about 1 year ago
JSON representation
Pull-streams for reading and writing in CouchDB.
- Host: GitHub
- URL: https://github.com/jamen/pull-couchdb
- Owner: jamen
- License: mit
- Created: 2018-04-22T01:42:01.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-22T01:45:27.000Z (about 8 years ago)
- Last Synced: 2025-02-08T02:24:53.519Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# pull-couchdb
Pull-streams for reading and writing in CouchDB.
## Install
```sh
npm i pull-couchdb
```
## Usage
### `allDocs(db)`
Requests CouchDB's [`GET /{db}/_all_docs`][1] and streams the results.
```js
pull(
allDocs('http://localhost:5984/foo_storage'),
drain(record => {
// ...
})
)
```
### `saveEach(db, params)`
Saves each object to CouchDB using [`POST /{db}`][2].
```js
pull(
values([
{ test: 'Hello world' }
{ test: 'foo' },
{ test: 'bar' }
]),
saveEach('http://localhost:5984/foo_storage'),
collect((err, results) => {
// ...
})
)
```
[1]: http://docs.couchdb.org/en/2.1.1/api/database/bulk-api.html#api-db-all-docs
[2]: http://docs.couchdb.org/en/2.1.1/api/database/common.html#post--db