couchdb-request
Advanced tools
Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "couchdb-request", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Minimilist couchdb client on top of request.", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "node --harmony test/test.js" | ||
}, | ||
@@ -18,3 +18,11 @@ "keywords": [ | ||
"author": "Jeffry L.", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"dependencies": { | ||
"debug": "^2.2.0", | ||
"request": "^2.74.0" | ||
}, | ||
"devDependencies": { | ||
"nock": "^8.0.0", | ||
"tape": "^4.6.0" | ||
} | ||
} |
114
README.md
# couchdb-request | ||
Minimalist couchdb client. | ||
[![Build Status](https://travis-ci.org/paragasu/couchdb-request.svg?branch=master)](https://travis-ci.org/paragasu/couchdb-request) | ||
Minimalist couchdb client on top of request. | ||
Unlike other couchdb-client, this module expose the powerful request object to enable chaining. | ||
This make it easy to use it as a proxy between client (browser) and couchDB server. | ||
This in turn allows us to do additional action like sending email confirmation after user successfully register or add additional check at the login form to rate limit login attempt. | ||
##Install | ||
$npm install couchdb-request | ||
##Method | ||
### API | ||
All method is basically a very light [request](https://www.npmjs.com/package/request) abstraction and every call will | ||
return the same request object. All method from [request](https://www.npmjs.com/package/request) module is available. | ||
Please refer the CouchDB API documentation at [docs.couchdb.org](http://docs.couchdb.org/en/1.6.1/http-api.html) for available | ||
REST API. | ||
#### configuration | ||
This api should be called first to set the correct database parameter | ||
before calling any database action method. | ||
- url full url sytax eg: https://admin:password@localhost:5984 | ||
#### database(url) | ||
Database name to query to | ||
- database name eg: booking | ||
#### get(id, [callback]) | ||
Get database value | ||
- id document id | ||
- callback *(optional)* function to execute after request complete | ||
#### put(id, data, [callback]) | ||
Insert data to database | ||
- id document id | ||
- data *(json)* object data to save | ||
- callback *(optional)* function to execute after request complete | ||
#### post(id, data, [callback]) | ||
Insert data to database | ||
- id document id | ||
- data *(json)* object data to save | ||
- callback *(optional)* function to execute after request complete | ||
#### del(id, callback) | ||
Delete data from database | ||
- id document id | ||
- data *(json)* object to save | ||
- callback function to execute after request complete | ||
#### save(id, data, callback) | ||
Update existing data. This api will automatically get the latest rev to use for updating the data. | ||
- id document id | ||
- data *(json)* object to save | ||
- callback function to execute after request complete | ||
#### view(design, opts, [callback]) | ||
Query rows of data using views | ||
- id view id | ||
- opts *(json)* options parameter as [documented here](http://docs.couchdb.org/en/1.6.1/api/ddoc/views.html) | ||
- callback *(optional)* function to execute after request complete | ||
##Usage example | ||
```javascript | ||
const bodyParser = require('body-parser'); | ||
const express = require('express'); | ||
const couchdb = require('couchdb-request')('https://admin:password@localhost:5984'); | ||
var app = express(); | ||
app.use(bodyParser.json()); | ||
app.post('/register', (req, res) => { | ||
couchdb | ||
.database('_users') //select database | ||
.put('org.couchdb.user:' + req.body.email, req.body) //method | ||
.on('error', err => console.log(err)) //log on error | ||
.on('response', result => sendEmailConfirmation(req.body)) //send email on success | ||
.pipe(res) //stream to browser | ||
}) | ||
app.listen(3000); | ||
``` | ||
Using callback function | ||
```javascript | ||
couchdb | ||
.database('_users') | ||
.get('org.couchdb.user:myuser@hello.com', res => { | ||
console.log(res); | ||
}) | ||
``` | ||
## Reference | ||
- [CouchDB API](http://docs.couchdb.org/en/1.6.1/http-api.html) | ||
- [CouchDB View Options](http://docs.couchdb.org/en/1.6.1/api/ddoc/views.html) | ||
- [Request documentation](https://github.com/request/request) | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
8709
7
156
1
115
0
2
2
+ Addeddebug@^2.2.0
+ Addedrequest@^2.74.0
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedms@2.0.0(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpsl@1.9.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)