https://github.com/hyper63/async-pouchdb
https://github.com/hyper63/async-pouchdb
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/hyper63/async-pouchdb
- Owner: hyper63
- Created: 2021-01-12T15:18:11.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-12T17:59:44.000Z (about 5 years ago)
- Last Synced: 2025-02-13T19:51:16.482Z (about 1 year ago)
- Language: JavaScript
- Size: 35.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# async-pouchdb
asyncPouchdb is a library that converts the pouchdb api functions into Async Monads
using the `crocks` module. An Async Monad is an Algerbraic Data Type that manages
asynchronous function calls in a lazy deterministic way.
## What is pouchdb?
check out https://pouchdb.com
## What is crocks?
check out https://crocks.dev
## Install
``` sh
npm install async-pouchdb
```
## Usage in NodeJS
``` js
const createPouchdb = require('async-pouchdb')
const pouchdb = createPouchdb()
const db = await pouchdb('http://localhost:5984/db').toPromise()
db.allDocs()
.fork(
err => console.log(err),
result => console.log(result)
)
```
## Options
The default driver is `http`, but you can use other pouchdb drivers as well.
When attaching a driver, it is important to provide both the name of the driver and
the plugin function. `{ name, driver }`.
## websql example
``` js
const createPouchdb = require('async-pouchdb')
const pouchdbAdapterNodeWebsql = require('pouchdb-adapter-node-websql')
const pouchdb = createPouchdb({
name: 'websql',
driver: pouchdbAdapterNodeWebsql
})
const db = await pouchdb('foo.db').toPromise()
db.allDocs()
.fork(
err => console.log(err),
result => console.log(result)
)
```
## memory example
``` js
const createPouchdb = require('async-pouchdb')
const pouchdbAdapterMemory = require('async-pouchdb')
const createPouchdb = require('async-pouchdb')
const pouchdb = createPouchdb({
name: 'memory',
driver: pouchdbAdapterMemory
})
const db = await pouchdb('foo.db').toPromise()
db.allDocs()
.fork(
err => console.log(err),
result => console.log(result)
)
```
## LICENSE
MIT
## CONTRIBUTIONS
Welcome
## ACKNOWLEDGEMENTS
* NodeJS - https://nodejs.org
* PouchDB - https://pouchdb.com
* Crocks - https://crocks.dev
## MAINTAINERS
* Tom Wilson - hyper63, LLC