Comparing version 1.0.0-beta3 to 1.0.0
@@ -1,20 +0,32 @@ | ||
everyone is welcome to contribute with patches, bug-fixes and new features | ||
# DCO | ||
1. create an [issue][2] on github so the community can comment on your idea | ||
2. fork `nano` in github | ||
3. create a new branch `git checkout -b my_branch` | ||
4. create tests for the changes you made | ||
5. make sure you pass both existing and newly inserted tests | ||
6. commit your changes | ||
7. push to your branch `git push origin my_branch` | ||
8. create a pull request | ||
To contribute to this project you must accept our [developer certificate of origin](https://github.com/dscape/nano/blob/master/README.md) | ||
to run tests make sure you npm test but also run tests without mocks: | ||
# Contributing | ||
Everyone is welcome to contribute with patches, bug-fixes and new features | ||
1. Create an [issue][2] on github so the community can comment on your idea | ||
2. Fork `nano` in github | ||
3. Create a new branch `git checkout -b my_branch` | ||
4. Create tests for the changes you made | ||
5. Make sure you pass both existing and newly inserted tests | ||
6. Commit your changes | ||
7. Push to your branch `git push origin my_branch` | ||
8. Create a pull request | ||
To run tests make sure you npm test but also run tests without mocks: | ||
``` sh | ||
npm run nock_off | ||
npm run test-cloudant | ||
``` | ||
check this [blogpost](http://writings.nunojob.com/2012/05/Mock-HTTP-Integration-Testing-in-Node.js-using-Nock-and-Specify.html) to learn more about how to write your own tests | ||
You can add verbose debug messages while running tests by doing: | ||
[2]: http://github.com/dscape/nano/issues | ||
``` | ||
DEBUG=* node your_nano_scripts.js | ||
``` | ||
You can turn nocks on and off using the `NOCK_OFF` environment variable. | ||
[issues]: http://github.com/cloudant/nodejs-cloudant/issues |
@@ -7,5 +7,4 @@ { | ||
"repository": "git://github.com/cloudant/nodejs-cloudant", | ||
"version": "1.0.0-beta3", | ||
"version": "1.0.0", | ||
"author": "Jason Smith <jason@cloudant.com>", | ||
"contributors": [], | ||
"keywords": [ | ||
@@ -19,23 +18,41 @@ "cloudant", | ||
"dependencies": { | ||
"request": "~2.33.0", | ||
"follow": "~0.11.2", | ||
"errs": "~0.2.4", | ||
"underscore": "~1.5.1" | ||
"request": "^2.53.0", | ||
"follow": "^0.11.4", | ||
"errs": "^0.3.0", | ||
"underscore": "^1.7.0", | ||
"debug": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"async": "~0.2.9", | ||
"specify": "~1.2.0", | ||
"nock": "~0.18.2" | ||
"async": "^0.9.0", | ||
"tape": "^3.0.0", | ||
"istanbul": "^0.3.2", | ||
"jshint": "^2.5.6", | ||
"jscs": "^1.7.0", | ||
"nock": "^0.48.1", | ||
"endswith": "^0.0.0", | ||
"tape-it": "^0.3.1", | ||
"pre-commit": "0.0.9" | ||
}, | ||
"scripts": { | ||
"test-cloudant": "env NOCK=on sh tests/cloudant/run-tests.sh", | ||
"test-cloudant-live": "sh tests/cloudant/run-tests.sh", | ||
"test": "node node_modules/specify/bin/specify -e NOCK=on", | ||
"compact": "node node_modules/specify/bin/specify -e NOCK=on -r compact", | ||
"nock_off": "node node_modules/specify/bin/specify" | ||
"test-cloudant": "tape tests/integration/cloudant/*.js", | ||
"test-cloudant-live": "NOCK_OFF=true tape tests/integration/cloudant/*.js", | ||
"test": "DEBUG=* NOCK_OFF=true istanbul cover tape tests/*/*/*.js", | ||
"unmocked": "NOCK_OFF=true tape tests/*/*/*.js", | ||
"mocked": "tape tests/*/*/*.js", | ||
"jshint": "jshint tests/*/*/*.js lib/*.js", | ||
"codestyle": "jscs -p google tests/*/*/*.js lib/*.js", | ||
"coverage": "open coverage/lcov-report/index.html", | ||
"checkcoverage": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100" | ||
}, | ||
"main": "./nano.js", | ||
"main": "./lib/nano.js", | ||
"engines": { | ||
"node": ">=0.6.0" | ||
} | ||
"node": ">=0.8.0" | ||
}, | ||
"pre-commit": [ | ||
"jshint", | ||
"codestyle", | ||
"mocked", | ||
"test", | ||
"checkcoverage" | ||
] | ||
} |
347
README.md
@@ -19,3 +19,3 @@ # Cloudant Node.js Client | ||
Notice that your package.json will now reflect this package. Everyting is working if you can run this command with no errors: | ||
Notice that your package.json will now reflect this package. Everything is working if you can run this command with no errors: | ||
@@ -29,3 +29,3 @@ $ node -e 'require("cloudant"); console.log("Cloudant works");' | ||
Initialize your Cloudant connection by supplying your *account* and *password*, and supplying a callback function to run when eveything is ready. | ||
Initialize your Cloudant connection by supplying your *account* and *password*, and supplying a callback function to run when everything is ready. | ||
@@ -38,20 +38,7 @@ ~~~ js | ||
Cloudant({account:me, password:password}, function(er, cloudant) { | ||
if (er) | ||
return console.log('Error connecting to Cloudant account %s: %s', me, er.message) | ||
Cloudant({account:me, password:password}, function(err, cloudant) { | ||
console.log('Connected to Cloudant') | ||
console.log('Connected to cloudant') | ||
cloudant.ping(function(er, reply) { | ||
if (er) | ||
return console.log('Failed to ping Cloudant. Did the network just go down?') | ||
console.log('Server version = %s', reply.version) | ||
console.log('I am %s and my roles are %j', reply.userCtx.name, reply.userCtx.roles) | ||
cloudant.db.list(function(er, all_dbs) { | ||
if (er) | ||
return console.log('Error listing databases: %s', er.message) | ||
console.log('All my databases: %s', all_dbs.join(', ')) | ||
}) | ||
cloudant.db.list(function(err, all_dbs) { | ||
console.log('All my databases: %s', all_dbs.join(', ')) | ||
}) | ||
@@ -63,5 +50,3 @@ }) | ||
Connected to cloudant | ||
Server version = 1.0.2 | ||
I am jhs and my roles are ["_admin","_reader","_writer"] | ||
Connected to Cloudant | ||
All my databases: example_db, jasons_stuff, scores | ||
@@ -73,19 +58,22 @@ | ||
The `.ping()` call is for clarity. In fact, when you initialize your conneciton, you implicitly ping Cloudant, and the "pong" value is passed to you as an optional extra argument: `Cloudant({account:"A", password:"P"}, function(er, cloudant, pong_reply) { ... })` | ||
To use the example code as-is, you must first install the `dotenv` package from npm, then create a `.env` file with your Cloudant credentials. For example: | ||
To use this code as-is, you must first type ` export cloudant_password="<whatever>"` in your shell. This is inconvenient, and you can invent your own alternative technique. | ||
~~~ | ||
npm install dotenv # Install ./node_modules/dotenv | ||
echo "/.env" >> .gitignore # Do not track .env in the revision history | ||
echo "cloudant_username=myaccount" > .env # Replace myaccount with your account name | ||
echo "cloudant_password='secret'" >> .env # Replace secret with your password | ||
~~~ | ||
### Security Note | ||
**DO NOT hard-code your password and commit it to Git**. Storing your password directly in your source code (even in old commits) is a serious security risk to your data. Whoever gains access to your software will now also have access read, write, and delete permission to your data. Think about GitHub security bugs, or contractors, or disgruntled employees, or lost laptops at a conference. If you check in your password, all of these situations become major liabilities. (Also, note that if you follow these instructions, the `export` command with your password will likely be in your `.bash_history` now, which is kind of bad. However, if you input a space before typing the command, it will not be stored in your history.) | ||
Here is simple but complete example of working with data: | ||
~~~ js | ||
require('dotenv').load() | ||
var Cloudant = require('Cloudant') | ||
var me = 'jhs' // Set this to your own account | ||
var me = process.env.cloudant_username | ||
var password = process.env.cloudant_password | ||
Cloudant({account:"me", password:password}, function(er, cloudant) { | ||
Cloudant({account:me, password:password}, function(er, cloudant) { | ||
if (er) | ||
@@ -99,3 +87,3 @@ return console.log('Error connecting to Cloudant account %s: %s', me, er.message) | ||
// specify the database we are going to use | ||
var alice = Cloudant.use('alice') | ||
var alice = cloudant.use('alice') | ||
// and insert a document in it | ||
@@ -125,38 +113,41 @@ alice.insert({ crazy: true }, 'rabbit', function(err, body, header) { | ||
- [Callback Signature](#callback-signature) | ||
- [Password Authentication](#password-authentication) | ||
- [Cloudant Local](#cloudant-local) | ||
- [Authorization and API Keys](#authorization-and-api-keys) | ||
- [Database Functions](#database-functions) | ||
- [cloudant.db.create(name, [callback])](#Cloudantdbcreatename-callback) | ||
- [cloudant.db.get(name, [callback])](#Cloudantdbgetname-callback) | ||
- [cloudant.db.destroy(name, [callback])](#Cloudantdbdestroyname-callback) | ||
- [cloudant.db.list([callback])](#Cloudantdblistcallback) | ||
- [cloudant.db.replicate(source, target, [opts], [callback])](#Cloudantdbreplicatesource-target-opts-callback) | ||
- [cloudant.db.changes(name, [params], [callback])](#Cloudantdbchangesname-params-callback) | ||
- [cloudant.db.follow(name, [params], [callback])](#Cloudantdbfollowname-params-callback) | ||
- [Cloudant.use(name)](#Cloudantusename) | ||
- [Cloudant.request(opts, [callback])](#Cloudantrequestopts-callback) | ||
- [Cloudant.config](#Cloudantconfig) | ||
- [Cloudant.updates([params], [callback])](#Cloudantupdatesparams-callback) | ||
- [Cloudant.follow_updates([params], [callback])](#Cloudantfollow_updatesparams-callback) | ||
- [Generate an API Key](#generate-an-api-key) | ||
- [Use an API Key](#use-an-api-key) | ||
- [Database Functions](#database-functions) | ||
- [cloudant.db.create(name, [callback])](#Cloudantdbcreatename-callback) | ||
- [cloudant.db.get(name, [callback])](#Cloudantdbgetname-callback) | ||
- [cloudant.db.destroy(name, [callback])](#Cloudantdbdestroyname-callback) | ||
- [cloudant.db.list([callback])](#Cloudantdblistcallback) | ||
- [cloudant.db.compact(name, [designname], [callback])](#Cloudantdbcompactname-designname-callback) | ||
- [cloudant.db.replicate(source, target, [opts], [callback])](#Cloudantdbreplicatesource-target-opts-callback) | ||
- [cloudant.db.changes(name, [params], [callback])](#Cloudantdbchangesname-params-callback) | ||
- [cloudant.db.follow(name, [params], [callback])](#Cloudantdbfollowname-params-callback) | ||
- [Cloudant.use(name)](#Cloudantusename) | ||
- [Cloudant.request(opts, [callback])](#Cloudantrequestopts-callback) | ||
- [Cloudant.config](#Cloudantconfig) | ||
- [Cloudant.updates([params], [callback])](#Cloudantupdatesparams-callback) | ||
- [Cloudant.follow_updates([params], [callback])](#Cloudantfollow_updatesparams-callback) | ||
- [Document Functions](#document-functions) | ||
- [db.insert(doc, [params], [callback])](#dbinsertdoc-params-callback) | ||
- [db.destroy(doc_id, rev, [callback])](#dbdestroydoc_id-rev-callback) | ||
- [db.get(doc_id, [params], [callback])](#dbgetdoc_id-params-callback) | ||
- [db.head(doc_id, [callback])](#dbheaddoc_id-callback) | ||
- [db.copy(src_doc, dest_doc, opts, [callback])](#dbcopysrc_doc-dest_doc-opts-callback) | ||
- [db.bulk(docs, [params], [callback])](#dbbulkdocs-params-callback) | ||
- [db.list([params], [callback])](#dblistparams-callback) | ||
- [db.fetch(doc_ids, [params], [callback])](#dbfetchdoc_ids-params-callback) | ||
- [db.insert(doc, doc_id, [callback])](#dbinsertdoc-doc_id-callback) | ||
- [db.destroy(doc_id, rev, [callback])](#dbdestroydoc_id-rev-callback) | ||
- [db.get(doc_id, [params], [callback])](#dbgetdoc_id-params-callback) | ||
- [db.head(doc_id, [callback])](#dbheaddoc_id-callback) | ||
- [db.copy(src_doc, dest_doc, opts, [callback])](#dbcopysrc_doc-dest_doc-opts-callback) | ||
- [db.bulk(docs, [params], [callback])](#dbbulkdocs-params-callback) | ||
- [db.list([params], [callback])](#dblistparams-callback) | ||
- [db.fetch(doc_ids, [params], [callback])](#dbfetchdoc_ids-params-callback) | ||
- [db.fetch_revs(doc_ids, [params], [callback])](#dbfetch_revsdoc_ids-params-callback) | ||
- [Multipart Functions](#multipart-functions) | ||
- [db.multipart.insert(doc, attachments, [params], [callback])](#dbmultipartinsertdoc-attachments-params-callback) | ||
- [db.multipart.get(doc_id, [params], [callback])](#dbmultipartgetdoc_id-params-callback) | ||
- [db.multipart.insert(doc, attachments, [params], [callback])](#dbmultipartinsertdoc-attachments-params-callback) | ||
- [db.multipart.get(doc_id, [params], [callback])](#dbmultipartgetdoc_id-params-callback) | ||
- [Attachment Functions](#attachments-functions) | ||
- [db.attachment.insert(doc_id, attname, att, contenttype, [params], [callback])](#dbattachmentinsertdoc_id-attname-att-contenttype-params-callback) | ||
- [db.attachment.get(doc_id, attname, [params], [callback])](#dbattachmentgetdoc_id-attname-params-callback) | ||
- [db.attachment.destroy(doc_id, attname, rev, [callback])](#dbattachmentdestroydoc_id-attname-rev-callback) | ||
- [Design Document Functions](#design-document-functions) | ||
- [db.view(designname, viewname, [params], [callback])](#dbviewdesignname-viewname-params-callback) | ||
- [db.show(designname, showname, doc_id, [params], [callback])](#dbshowdesignname-showname-doc_id-params-callback) | ||
- [db.atomic(designname, updatename, doc_id, [body], [callback])](#dbatomicdesignname-updatename-doc_id-body-callback) | ||
- [db.search(designname, viewname, [params], [callback])](#dbsearchdesignname-searchname-params-callback) | ||
- [db.attachment.insert(doc_id, attname, att, contenttype, [params], [callback])](#dbattachmentinsertdoc_id-attname-att-contenttype-params-callback) | ||
- [db.attachment.get(doc_id, attname, [params], [callback])](#dbattachmentgetdoc_id-attname-params-callback) | ||
- [db.attachment.destroy(doc_id, attname, rev, [callback])](#dbattachmentdestroydoc_id-attname-rev-callback) | ||
- [Design Document Functions](#design-document-functions) | ||
- [db.view(designname, viewname, [params], [callback])](#dbviewdesignname-viewname-params-callback) | ||
- [db.search(designname, viewname, [params], [callback])](#dbsearchdesignname-searchname-params-callback) | ||
- [Cloudant Search](#cloudant-search) | ||
@@ -167,5 +158,5 @@ - [Cloudant Query](#cloudant-query) | ||
- [Advanced Features](#advanced-features) | ||
- [Extending the Cloudant Library](#extending-the-cloudant-library) | ||
- [Pipes](#pipes) | ||
- [tests](#tests) | ||
- [Extending the Cloudant Library](#extending-the-cloudant-library) | ||
- [Pipes](#pipes) | ||
- [Tests](#tests) | ||
@@ -192,2 +183,19 @@ ### Initialization | ||
If you would prefer, you can also initialize Cloudant synchronously by omitting the callback. | ||
This can help avoid messy code if you are requiring the Cloudant library in many places in your app. You should note that this method does not verify that your Cloudant credentials are correct - you would have to use the [ping](#cloudantpingcallback) for that. | ||
A simple example of initializing sychronously is: | ||
~~~ js | ||
var Cloudant = require('cloudant')({account:me, password:password}); | ||
var db = Cloudant.use("animals"); | ||
db.get("dog", function(err, data) { | ||
// rest of your code goes here | ||
}); | ||
~~~ | ||
### cloudant.ping([callback]) | ||
@@ -218,2 +226,28 @@ | ||
### Password Authentication | ||
By default, when you connect to your cloudant account (i.e. "me.cloudant.com"), you authenticate as the account owner (i.e. "me"). However, you can use Cloudant with any username and password. Just provide an additional "username" option when you initialize Cloudant. This will connect to your account, but using the username as the authenticated user. (And of course, use the appropriate password.) | ||
~~~ js | ||
Cloudant({account:"me", username:"somebody", password:"somebody's secret"}, function(er, cloudant, reply) { | ||
if (er) | ||
throw er | ||
console.log('Connected with username: %s', reply.userCtx.name) | ||
}) | ||
~~~ | ||
### Cloudant Local | ||
If you use Cloudant Local, everything works exactly the same, except you provide a *hostname* parameter to indicate which server to use: | ||
~~~ js | ||
Cloudant({hostname:"companycloudant.local", username:"somebody", password:"somebody's secret"}, function(er, cloudant, reply) { | ||
if (er) | ||
throw er | ||
console.log('Connected with username: %s', reply.userCtx.name) | ||
}) | ||
~~~ | ||
## Authorization and API Keys | ||
@@ -244,13 +278,60 @@ | ||
~~~ js | ||
// Set read-only access for this key. | ||
var db = "my_database" | ||
cloudant.set_permissions({database:db, username:api.key, roles:['_reader']}, function(er, result) { | ||
// Set the security for three users. | ||
var db = "my_database", | ||
security = { | ||
cloudant: { | ||
nobody: [] | ||
fred : [ '_reader', '_writer', '_admin', '_replicator' ], | ||
isdaingialkyciffestontsk: [ '_reader', '_writer' ] | ||
} | ||
}; | ||
cloudant.set_security( database, security, function(er, result) { | ||
if (er) | ||
throw er | ||
console.log('%s now has read-only access to %s', api.key, db) | ||
}) | ||
}) | ||
console.log(result); | ||
}); | ||
~~~ | ||
or read the security settings for a database | ||
~~~ js | ||
var db = "my_database", | ||
cloudant.view_security( database, function(er, result) { | ||
if (er) | ||
throw er | ||
console.log(result); | ||
}); | ||
~~~ | ||
Output: | ||
``` | ||
{ | ||
"cloudant": { | ||
"nobody": [], | ||
"fred": [ | ||
"_reader", | ||
"_writer", | ||
"_admin", | ||
"_replicator" | ||
], | ||
"isdaingialkyciffestontsk": [ | ||
"_reader", | ||
"_writer" | ||
] | ||
} | ||
} | ||
``` | ||
See the Cloudant API for full details](https://docs.cloudant.com/api.html#authorization) | ||
### Use an API Key | ||
@@ -269,2 +350,32 @@ | ||
## CORS | ||
If you need to access your Cloudant database from a web application that is served from a domain other than your Cloudant account, you will need to enable CORS (Cross-origin resource sharing). | ||
e.g. enable CORS from any domain: | ||
~~~ js | ||
cloudant.cors({ enable_cors: true, allow_credentials: true, origins: ["*"]}, function(err, data) { | ||
console.log(err, data); | ||
}; | ||
~~~ | ||
or enable access from a list of specified domains: | ||
~~~ js | ||
cloudant.cors({ enable_cors: true, allow_credentials: true, origins: [ "https://mydomain.com","https://mysubdomain.mydomain.com"]}, function(err, data) { | ||
console.log(err, data); | ||
}; | ||
~~~ | ||
or disable CORS access | ||
~~~ js | ||
cloudant.cors({ enable_cors: false }, function(err, data) { | ||
console.log(err, data); | ||
}; | ||
~~~ | ||
See <https://docs.cloudant.com/api.html#cors> for further details. | ||
## Database Functions | ||
@@ -382,3 +493,3 @@ | ||
* `opts.att` – the attachment name | ||
* `opts.params` – query string parameters, appended after any existing `opts.path`, `opts.doc`, or `opts.att` | ||
* `opts.qs` – query string parameters, appended after any existing `opts.path`, `opts.doc`, or `opts.att` | ||
* `opts.content_type` – the content type of the request, default to `json` | ||
@@ -408,3 +519,3 @@ * `opts.headers` – additional http headers, overrides existing ones | ||
### Cloudant.follow_updates([params], [callback]) | ||
### Cloudant.followUpdates([params], [callback]) | ||
@@ -415,4 +526,4 @@ Uses [follow](https://github.com/iriscouch/follow) to create a solid | ||
~~~js | ||
var feed = Cloudant.follow_updates({since: "now"}) | ||
~~~ js | ||
var feed = Cloudant.followUpdates({since: "now"}) | ||
feed.on('change', function (change) { | ||
@@ -494,3 +605,3 @@ console.log("change: ", change) | ||
Bulk operations(update/delete/insert) on the database, refer to the | ||
[Documentation](http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API). | ||
[Documentation](http://docs.couchdb.org/en/latest/api/database/bulk-api.html). | ||
@@ -514,10 +625,10 @@ ### db.list([params], [callback]) | ||
Bulk fetch of the database documents, `doc_ids` are specified as per | ||
[CouchDB doc](http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API). | ||
[CouchDB doc](http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_all_docs). | ||
Additional query string `params` can be specified, `include_docs` is always set | ||
to `true`. | ||
### db.fetch_revs(doc_ids, [params], [callback]) | ||
### db.fetchRevs(doc_ids, [params], [callback]) | ||
Bulk fetch of the revisions of the database documents, `doc_ids` are specified as per | ||
[CouchDB doc](http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API). | ||
[CouchDB doc](http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_all_docs). | ||
Additional query string `params` can be specified, this is the same method as fetch but | ||
@@ -530,5 +641,5 @@ `include_docs` is not automatically set to `true`. | ||
### db.multipart.insert(doc, attachments, doc_id, [callback]) | ||
### db.multipart.insert(doc, attachments, params, [callback]) | ||
Insert a `doc` together with `attachments` and optional `params`. Refer to the [CouchDB multipart documentation](http://wiki.apache.org/couchdb/HTTP_Document_API#Multiple_Attachments) for more details. | ||
Insert a `doc` together with `attachments` and optional `params`. If params is a string, its assumed as the intended document name. if params is an object, its passed as query string parameters and `docName` is checked for defining the document name. Refer to the [CouchDB multipart documentation](http://docs.couchdb.org/en/latest/api/document/common.html?highlight=multipart#creating-multiple-attachments) for more details. | ||
@@ -555,3 +666,3 @@ `attachments` must be an array of objects with `name`, `data` and `content_type` properties. For example: | ||
Get `doc_id` together with its attachments via `multipart/related` request with optional query string additions | ||
`params`. Refer to the [doc](http://wiki.apache.org/Cloudant/HTTP_Document_API#Getting_Attachments_With_a_Document) for more details. The multipart response body is a `Buffer`. | ||
`params`. Refer to the [doc](http://docs.couchdb.org/en/latest/api/document/common.html?highlight=multipart#efficient-multiple-attachments-retrieving) for more details. The multipart response body is a `Buffer`. | ||
@@ -569,3 +680,3 @@ ~~~ js | ||
Inserts an attachment `attname` to `doc_id`. In most cases `params.rev` is required. Refer to the [doc](http://wiki.apache.org/Cloudant/HTTP_Document_API) for more details. | ||
Inserts an attachment `attname` to `doc_id`. In most cases `params.rev` is required. Refer to the [doc](http://docs.couchdb.org/en/latest/api/document/common.html?highlight=multipart#retrieving-attachments-content) for more details. | ||
@@ -622,9 +733,9 @@ ~~~ js | ||
### db.attachment.destroy(doc_id, attname, rev, [callback]) | ||
### db.attachment.destroy(docname, attname, [params], [callback]) | ||
Destroy attachment `attname` of `doc_id`'s revision `rev`. | ||
Destroy attachment `attname` of `docname`'s revision `rev`. | ||
~~~ js | ||
var rev = '1-4701d73a08ce5c2f2983bf7c9ffd3320' | ||
alice.attachment.destroy('rabbit', 'rabbit.png', rev, function(err, body) { | ||
alice.attachment.destroy('rabbit', 'rabbit.png', {'rev':rev}, function(err, body) { | ||
if (!err) | ||
@@ -654,51 +765,2 @@ console.log(body) | ||
### db.view_with_list(designname, viewname, listname, [params], [callback]) | ||
Call a list function feeded by the given view of the specified design document. | ||
~~~ js | ||
alice.view_with_list('characters', 'crazy_ones', 'my_list', function(err, body) { | ||
if (!err) | ||
console.log(body) | ||
}) | ||
~~~ | ||
### db.show(designname, showname, doc_id, [params], [callback]) | ||
Call a show function of the specified design for the document specified by doc_id with | ||
optional query string additions `params`. | ||
~~~ js | ||
alice.show('characters', 'format_doc', '3621898430', function(err, doc) { | ||
if (!err) | ||
console.log(doc) | ||
}) | ||
~~~ | ||
Take a look at the [CouchDB wiki](http://wiki.apache.org/couchdb/Formatting_with_Show_and_List#Showing_Documents) for possible query paramaters and more information on show functions. | ||
### db.atomic(designname, updatename, doc_id, [body], [callback]) | ||
Call the design's update function with the specified doc in input. | ||
~~~ js | ||
db.atomic("update", "inplace", "foobar", {field: "foo", value: "bar"}, function (error, response) { | ||
assert.equal(error, undefined, "failed to update") | ||
assert.equal(response.foo, "bar", "update worked") | ||
}) | ||
~~~ | ||
Note that the data is sent in the body of the request. An example update handler follows: | ||
~~~ js | ||
"updates": { | ||
"in-place" : "function(doc, req) { | ||
var field = req.form.field; | ||
var value = req.form.value; | ||
var message = 'set '+field+' to '+value; | ||
doc[field] = value; | ||
return [doc, message]; | ||
}" | ||
~~~ | ||
### db.search(designname, searchname, [params], [callback]) | ||
@@ -811,3 +873,3 @@ | ||
db.insert(doc, function (er, result) { | ||
db.insert(ddoc, function (er, result) { | ||
if (er) | ||
@@ -897,3 +959,3 @@ throw er | ||
console.log('user is %s and has these roles: %j', | ||
session.userCtx.user, session.userCtx.roles); | ||
session.userCtx.name, session.userCtx.roles); | ||
}); | ||
@@ -904,3 +966,3 @@ ~~~ | ||
Besides the account and password options, you can add an optionsl `request_defaults` value, which will initialize Request (the underlying HTTP library) as you need it. | ||
Besides the account and password options, you can add an optionsl `requestDefaults` value, which will initialize Request (the underlying HTTP library) as you need it. | ||
@@ -914,3 +976,3 @@ ~~~ js | ||
, "password" : "secret" | ||
, "request_defaults": { "proxy": "http://localhost:8080" } | ||
, "requestDefaults": { "proxy": "http://localhost:8080" } | ||
} | ||
@@ -927,3 +989,3 @@ | ||
A very important configuration parameter if you have a high traffic website and are using Cloudant is setting up the `pool.size`. By default, the node.js https global agent (client) has a certain size of active connections that can run simultaneously, while others are kept in a queue. Pooling can be disabled by setting the `agent` property in `request_defaults` to false, or adjust the global pool size using: | ||
A very important configuration parameter if you have a high traffic website and are using Cloudant is setting up the `pool.size`. By default, the node.js https global agent (client) has a certain size of active connections that can run simultaneously, while others are kept in a queue. Pooling can be disabled by setting the `agent` property in `requestDefaults` to false, or adjust the global pool size using: | ||
@@ -935,3 +997,3 @@ ~~~ js | ||
You can also increase the size in your calling context using `request_defaults` if this is problematic. refer to the [request] documentation and examples for further clarification. | ||
You can also increase the size in your calling context using `requestDefaults` if this is problematic. refer to the [request] documentation and examples for further clarification. | ||
@@ -949,3 +1011,3 @@ Here is an example of explicitly using the keep alive agent (installed using `npm install agentkeepalive`), especially useful to limit your open sockets when doing high-volume access to Cloudant: | ||
var Cloudant = require('cloudant') | ||
Cloudant({account:"me", password:"secret", request_defaults:{agent:myagent}}, function(err, cloudant) { | ||
Cloudant({account:"me", password:"secret", requestDefaults:{agent:myagent}}, function(err, cloudant) { | ||
// Using Cloudant with myagent... | ||
@@ -1064,2 +1126,3 @@ }) | ||
# Note the leading space to keep this command out of the Bash history. | ||
$ HISTCONTROL="$HISTCONTROL:ignorespace" | ||
$ npm config set cloudant_password "ask jason for the password" # <- Not the real password | ||
@@ -1066,0 +1129,0 @@ $ npm run test-cloudant-live |
@@ -1,2 +0,2 @@ | ||
{ "timeout" : 20000 | ||
{ "timeout" : 5000 | ||
, "couch" : "http://localhost:5984" | ||
@@ -3,0 +3,0 @@ , "admin" : "http://admin:password@localhost:5984" |
[ | ||
{ "method" : "post" | ||
, "path" : "/api/generate_api_key" | ||
, "reqheaders": {"authorization":"Basic bm9kZWpzOnNlY3JldA=="} | ||
, "response" : "{\"password\": \"OQEDHdgbyAw0bapKYOQGiP64\", \"ok\": true, \"key\": \"isdaingialkyciffestontsk\"}" | ||
{ "method" : "get" | ||
, "path" : "/" | ||
, "status" : 200 | ||
, "response" : "{\"couchdb\":\"Welcome\",\"version\":\"1.0.2\",\"cloudant_build\":\"1996\"}" | ||
} | ||
, { "method" : "post" | ||
, "path" : "/api/set_permissions" | ||
, "body" : "database=nodejs%2Fthird_party_db&username=isdaingialkyciffestontsk&roles=_reader&roles=_writer" | ||
, "reqheaders": {"authorization":"Basic bm9kZWpzOnNlY3JldA=="} | ||
, "response" : "{\"ok\": true}" | ||
, { "method" : "get" | ||
, "path" : "/_session" | ||
, "reqheaders": {"authorization":"Basic aXNkYWluZ2lhbGt5Y2lmZmVzdG9udHNrOk9RRURIZGdieUF3MGJhcEtZT1FHaVA2NA=="} | ||
, "status" : 200 | ||
, "response" : "{\"ok\":true,\"info\":{\"authentication_db\":\"_users\",\"authentication_handlers\":[\"cookie\",\"default\"],\"authenticated\":\"default\"},\"userCtx\":{\"name\":\"isdaingialkyciffestontsk\",\"roles\":[]}}" | ||
} | ||
, { "method" : "get" | ||
, "path" : "/" | ||
, "status" : 200 | ||
, "response" : "{\"couchdb\":\"Welcome\",\"version\":\"1.0.2\",\"cloudant_build\":\"1996\"}" | ||
} | ||
, { "method" : "get" | ||
, "path" : "/_session" | ||
, "reqheaders": {"authorization":"Basic aXNkYWluZ2lhbGt5Y2lmZmVzdG9udHNrOk9RRURIZGdieUF3MGJhcEtZT1FHaVA2NA=="} | ||
, "status" : 200 | ||
, "response" : "{\"ok\":true,\"info\":{\"authentication_db\":\"_users\",\"authentication_handlers\":[\"cookie\",\"default\"],\"authenticated\":\"default\"},\"userCtx\":{\"name\":\"isdaingialkyciffestontsk\",\"roles\":[]}}" | ||
} | ||
] |
[ | ||
{ "method" : "put" | ||
, "path" : "/query_db" | ||
, "reqheaders": {"authorization":"Basic bm9kZWpzOnNlY3JldA=="} | ||
, "path" : "/cloudant_query" | ||
, "headers" : {"authorization":"Basic bm9kZWpzOnNlY3JldA=="} | ||
, "response" : "{\"ok\":true}" | ||
@@ -9,3 +9,3 @@ } | ||
, { "method" : "post" | ||
, "path" : "/query_db" | ||
, "path" : "/cloudant_query" | ||
, "body" : "*" | ||
@@ -15,3 +15,3 @@ , "response" : "{\"ok\":true, \"id\":\"69cf679387a676151ec8c5de6d1cb9df\", \"rev\":\"1-d1a0252d7e12b821abc4e4f02002a410\"}" | ||
, { "method" : "post" | ||
, "path" : "/query_db" | ||
, "path" : "/cloudant_query" | ||
, "body" : "*" | ||
@@ -21,3 +21,3 @@ , "response" : "{\"ok\":true, \"id\":\"61336be02a970cd6c547ae3ce7984e29\", \"rev\":\"1-c7aab454f4e7393f5d684c079a020816\"}" | ||
, { "method" : "post" | ||
, "path" : "/query_db" | ||
, "path" : "/cloudant_query" | ||
, "body" : "*" | ||
@@ -27,3 +27,3 @@ , "response" : "{\"ok\":true, \"id\":\"96e35c918abfa28d11278751129cfe92\", \"rev\":\"1-a388649f41726446cf736b129b1bf3fe\"}" | ||
, { "method" : "post" | ||
, "path" : "/query_db" | ||
, "path" : "/cloudant_query" | ||
, "body" : "*" | ||
@@ -34,3 +34,3 @@ , "response" : "{\"ok\":true, \"id\":\"69cf679387a676151ec8c5de6d1cc63a\", \"rev\":\"1-2bbb34d79d04a1fa807bcf9a66356c76\"}" | ||
, { "method" : "post" | ||
, "path" : "/query_db/_index" | ||
, "path" : "/cloudant_query/_index" | ||
, "body" : "{\"name\":\"first-name\",\"type\":\"json\",\"index\":{\"fields\":[\"name\"]}}" | ||
@@ -40,3 +40,3 @@ , "response" : "{\"result\":\"created\"}" | ||
, { "method" : "post" | ||
, "path" : "/query_db/_index" | ||
, "path" : "/cloudant_query/_index" | ||
, "body" : "{\"name\":\"last-name\",\"type\":\"json\",\"index\":{\"fields\":[\"last\"]}}" | ||
@@ -47,3 +47,3 @@ , "response" : "{\"result\":\"created\"}" | ||
, { "method" : "get" | ||
, "path" : "/query_db/_index" | ||
, "path" : "/cloudant_query/_index" | ||
, "response" : "{\"indexes\":[{\"ddoc\":null,\"name\":\"_all_docs\",\"type\":\"special\",\"def\":{\"fields\":[{\"_id\":\"asc\"}]}},{\"ddoc\":\"_design/862f3b5321a1987df6d36dc8607fc678879210b5\",\"name\":\"first-name\",\"type\":\"json\",\"def\":{\"fields\":[{\"name\":\"asc\"}]}},{\"ddoc\":\"_design/9abb3691d4367734ad2ceb99d67287750988f0a8\",\"name\":\"last-name\",\"type\":\"json\",\"def\":{\"fields\":[{\"last\":\"asc\"}]}}]}" | ||
@@ -53,3 +53,3 @@ } | ||
, { "method" : "post" | ||
, "path" : "/query_db/_find" | ||
, "path" : "/cloudant_query/_find" | ||
, "body" : "{\"selector\":{\"name\":\"Alice\"}}" | ||
@@ -59,3 +59,3 @@ , "response" : "{\"docs\":[{\"_id\":\"9b7095b7afc2c2306092499b1759584d\",\"_rev\":\"1-d1a0252d7e12b821abc4e4f02002a410\",\"name\":\"Alice\",\"last\":\"Cooper\",\"score\":15},{\"_id\":\"e3246fdbd7128ebaba0a09114cddcb59\",\"_rev\":\"1-c7aab454f4e7393f5d684c079a020816\",\"name\":\"Alice\",\"last\":\"Barnham\",\"score\":12}]}" | ||
, { "method" : "post" | ||
, "path" : "/query_db/_find" | ||
, "path" : "/cloudant_query/_find" | ||
, "body" : "{\"selector\":{\"last\":\"Barnham\"}}" | ||
@@ -66,3 +66,3 @@ , "response" : "{\"docs\":[{\"_id\":\"e3246fdbd7128ebaba0a09114cddcb59\",\"_rev\":\"1-c7aab454f4e7393f5d684c079a020816\",\"name\":\"Alice\",\"last\":\"Barnham\",\"score\":12}]}" | ||
, { "method" : "delete" | ||
, "path" : "/query_db/_index/_design/9abb3691d4367734ad2ceb99d67287750988f0a8/json/last-name" | ||
, "path" : "/cloudant_query/_index/_design/9abb3691d4367734ad2ceb99d67287750988f0a8/json/last-name" | ||
, "response" : "{\"ok\":true}" | ||
@@ -72,5 +72,5 @@ } | ||
, { "method" : "delete" | ||
, "path" : "/query_db" | ||
, "path" : "/cloudant_query" | ||
, "response" : "{\"ok\":true}" | ||
} | ||
] |
[ | ||
{ "method" : "put" | ||
, "path" : "/search_db" | ||
, "reqheaders": {"authorization":"Basic bm9kZWpzOnNlY3JldA=="} | ||
, "path" : "/cloudant_search" | ||
, "headers": {"authorization":"Basic bm9kZWpzOnNlY3JldA=="} | ||
, "response" : "{\"ok\":true}" | ||
} | ||
, { "method" : "post" | ||
, "path" : "/search_db/_bulk_docs" | ||
, "path" : "/cloudant_search/_bulk_docs" | ||
, "body" : "*" | ||
@@ -14,7 +14,7 @@ , "response" : "[{\"id\":\"3d68bd1be24220ab36d0ad6a97ec5f9d\",\"rev\":\"1-3e1f4ff28eaa99dc471ff994051f30ab\"},{\"id\":\"3d68bd1be24220ab36d0ad6a97ec699a\",\"rev\":\"1-35c7c65df2cbb9a5f501717e78c508ee\"},{\"id\":\"_design/library\",\"rev\":\"1-81f3eca990862b9771b971d7a9ccada3\"}]" | ||
, { "method" : "get" | ||
, "path" : "/search_db/_design/library/_search/books?q=author%3Acharles" | ||
, "path" : "/cloudant_search/_design/library/_search/books?q=author%3Acharles" | ||
, "response" : "{\"total_rows\":1,\"bookmark\":\"g2wAAAABaANkAB1kYmNvcmVAZGI2LnNsaW5nLmNsb3VkYW50Lm5ldGwAAAACbgQAAAAAgG4EAP___79qaAJGP8iMWIAAAABhAGo\",\"rows\":[{\"id\":\"a_tale\",\"order\":[0.19178301095962524,0],\"fields\":{}}]}" | ||
} | ||
, { "method" : "get" | ||
, "path" : "/search_db/_design/library/_search/books?q=title%3Atwo" | ||
, "path" : "/cloudant_search/_design/library/_search/books?q=title%3Atwo" | ||
, "response" : "{\"total_rows\":2,\"bookmark\":\"g1AAAACIeJzLYWBgYMpgTmGQTUlKzi9KdUhJMtcrzsnMS9dLzskvTUnMK9HLSy3JASlLcgCSSfX____PymBysz_RE9EAFEhkIFJ7HguQZGgAUkAT9oONOLy4igFsRBYAPRQqlQ\",\"rows\":[{\"id\":\"towers\",\"order\":[0.19178301095962524,0],\"fields\":{}},{\"id\":\"a_tale\",\"order\":[0.1534264087677002,0],\"fields\":{}}]}" | ||
@@ -24,5 +24,5 @@ } | ||
, { "method" : "delete" | ||
, "path" : "/search_db" | ||
, "path" : "/cloudant_search" | ||
, "response" : "{\"ok\":true}" | ||
} | ||
] |
@@ -5,7 +5,7 @@ [ | ||
, "status" : 201 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
, { "method" : "put" | ||
, "path" : "/design_compact/_design/alice" | ||
, "body" : "{\"views\":{\"by_id\":{\"map\":\"function (doc) { emit(doc._id, doc); }\"}}}" | ||
, "body" : "*" | ||
, "status" : 201 | ||
@@ -17,3 +17,3 @@ , "response" : "{\"ok\":true,\"id\":\"_design/alice\",\"rev\":\"1-14e6bc\"}" | ||
, "path" : "/design_compact/foobaz" | ||
, "body" : "{\"foo\":\"baz\"}" | ||
, "body" : "*" | ||
, "response" : "{\"ok\":true,\"id\":\"foobaz\",\"rev\":\"1-611488\"}" | ||
@@ -30,2 +30,5 @@ } | ||
} | ||
, { "path" : "/design_compact" | ||
, "response" : "{\"compact_running\": false}" | ||
} | ||
, { "path" : "/design_compact/_design/alice/_view/by_id" | ||
@@ -36,4 +39,4 @@ , "response" : "{ \"total_rows\": 0, \"offset\": 0, \"rows\": [] }" | ||
, "path" : "/design_compact" | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
] | ||
] |
@@ -9,3 +9,3 @@ [ | ||
, "path" : "/design_list/_design/people" | ||
, "body" : "{\"views\":{\"by_name_and_city\":{\"map\":\"function (doc) { emit([doc.name, doc.city], doc._id); }\"}},\"lists\":{\"my_list\":\"function (head, req) { send('Hello'); }\"}}" | ||
, "body" : "*" | ||
, "status" : 201 | ||
@@ -17,3 +17,3 @@ , "response" : "{\"ok\":true,\"id\":\"_design/people\",\"rev\":\"1-14e6bc\"}" | ||
, "path" : "/design_list/p_derek" | ||
, "body" : "{\"name\":\"Derek\",\"city\":\"San Francisco\"}" | ||
, "body" : "*" | ||
, "response" : "{\"ok\":true,\"id\":\"p_derek\",\"rev\":\"1-4c6114\"}" | ||
@@ -24,3 +24,3 @@ } | ||
, "path" : "/design_list/p_randall" | ||
, "body" : "{\"name\":\"Randall\",\"city\":\"San Francisco\"}" | ||
, "body" : "*" | ||
, "response" : "{\"ok\":true,\"id\":\"p_randall\",\"rev\":\"1-4c6114\"}" | ||
@@ -31,3 +31,3 @@ } | ||
, "path" : "/design_list/p_nuno" | ||
, "body" : "{\"name\":\"Nuno\",\"city\":\"New York\"}" | ||
, "body" : "*" | ||
, "response" : "{\"ok\":true,\"id\":\"p_nuno\",\"rev\":\"1-4c6114\"}" | ||
@@ -42,4 +42,4 @@ } | ||
, "status" : 200 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
] | ||
] |
@@ -5,7 +5,7 @@ [ | ||
, "status" : 201 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
, { "method" : "put" | ||
, "path" : "/design_multiple/_design/alice" | ||
, "body" : "{\"views\":{\"by_id\":{\"map\":\"function (doc) { emit(doc._id, doc); }\"}}}" | ||
, "body" : "*" | ||
, "status" : 201 | ||
@@ -40,4 +40,4 @@ , "response" : "{\"ok\":true,\"id\":\"_design/alice\",\"rev\":\"1-14e6bc\"}" | ||
, "status" : 200 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
] | ||
] |
@@ -5,7 +5,7 @@ [ | ||
, "status" : 201 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
, { "method" : "put" | ||
, "path" : "/design_query/_design/people" | ||
, "body" : "{\"views\":{\"by_name_and_city\":{\"map\":\"function (doc) { emit([doc.name, doc.city], doc._id); }\"}}}" | ||
, "body" : "*" | ||
, "status" : 201 | ||
@@ -17,3 +17,3 @@ , "response" : "{\"ok\":true,\"id\":\"_design/people\",\"rev\":\"1-14e6bc\"}" | ||
, "path" : "/design_query/p_derek" | ||
, "body" : "{\"name\":\"Derek\",\"city\":\"San Francisco\"}" | ||
, "body" : "*" | ||
, "response" : "{\"ok\":true,\"id\":\"p_derek\",\"rev\":\"1-4c6114\"}" | ||
@@ -24,3 +24,3 @@ } | ||
, "path" : "/design_query/p_randall" | ||
, "body" : "{\"name\":\"Randall\",\"city\":\"San Francisco\"}" | ||
, "body" : "*" | ||
, "response" : "{\"ok\":true,\"id\":\"p_randall\",\"rev\":\"1-4c6114\"}" | ||
@@ -31,3 +31,3 @@ } | ||
, "path" : "/design_query/p_nuno" | ||
, "body" : "{\"name\":\"Nuno\",\"city\":\"New York\"}" | ||
, "body" : "*" | ||
, "response" : "{\"ok\":true,\"id\":\"p_nuno\",\"rev\":\"1-4c6114\"}" | ||
@@ -47,4 +47,4 @@ } | ||
, "status" : 200 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
] | ||
] |
@@ -9,3 +9,3 @@ [ | ||
, "path" : "/design_search/_design/people/_search" | ||
, "body" : "{\"views\":{\"by_name_and_city\":{\"map\":\"function (doc) { emit([doc.name, doc.city], doc._id); }\"}}}" | ||
, "body" : "*" | ||
, "status" : 201 | ||
@@ -17,3 +17,3 @@ , "response" : "{\"ok\":true,\"id\":\"_design/people/_search\",\"rev\":\"1-14e6bc\"}" | ||
, "path" : "/design_search/p_derek" | ||
, "body" : "{\"name\":\"Derek\",\"city\":\"San Francisco\"}" | ||
, "body" : "*" | ||
, "response" : "{\"ok\":true,\"id\":\"p_derek\",\"rev\":\"1-4c6114\"}" | ||
@@ -24,3 +24,3 @@ } | ||
, "path" : "/design_search/p_randall" | ||
, "body" : "{\"name\":\"Randall\",\"city\":\"San Francisco\"}" | ||
, "body" : "*" | ||
, "response" : "{\"ok\":true,\"id\":\"p_randall\",\"rev\":\"1-4c6114\"}" | ||
@@ -31,3 +31,3 @@ } | ||
, "path" : "/design_search/p_nuno" | ||
, "body" : "{\"name\":\"Nuno\",\"city\":\"New York\"}" | ||
, "body" : "*" | ||
, "response" : "{\"ok\":true,\"id\":\"p_nuno\",\"rev\":\"1-4c6114\"}" | ||
@@ -34,0 +34,0 @@ } |
@@ -5,7 +5,7 @@ [ | ||
, "status" : 201 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
, { "method" : "put" | ||
, "path" : "/design_show/_design/people" | ||
, "body" : "{\"shows\":{\"singleDoc\":\"function (doc, req) {\\n if(req.query.format === 'json' || !req.query.format) {\\n return { body: JSON.stringify({ name: doc.name, city: doc.city, format: 'json' }), headers: { 'Content-Type': 'application/json' } };\\n }\\n if(req.query.format === 'html') {\\n return { body: 'Hello Clemens!', headers: { 'Content-Type': 'text/html' } };\\n }\\n }\"}}" | ||
, "body" : "*" | ||
, "status" : 201 | ||
@@ -43,4 +43,4 @@ , "response" : "{\"ok\":true,\"id\":\"_design/people\",\"rev\":\"1-14e6bc\"}" | ||
, "status" : 200 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
] | ||
] |
@@ -5,3 +5,3 @@ [ | ||
, "status" : 201 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
@@ -22,4 +22,4 @@ , { "method" : "put" | ||
, "status" : 200 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
] |
@@ -5,3 +5,3 @@ [ | ||
, "status" : 201 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
@@ -14,7 +14,39 @@ , { "method" : "put" | ||
} | ||
, { "method" : "put" | ||
, "path" : "/multipart_insert/foobar" | ||
, "body" : "*" | ||
, "status" : 201 | ||
, "response" : "{\"ok\": true, \"id\": \"foobar\", \"rev\": \"1-921bd51\" }" | ||
} | ||
, { "method" : "put" | ||
, "path" : "/multipart_insert/mydoc/one" | ||
, "body" : "Hello World!" | ||
, "status" : 201 | ||
, "response" : "{\"ok\": true, \"id\": \"one\", \"rev\": \"1-921bd51\" }" | ||
} | ||
, { "path" : "/multipart_insert/mydoc" | ||
, "status" : 200 | ||
, "response" : "{\"_id\": \"mydoc\", \"_rev\": \"1-921bd51\", \"_attachments\": { \"one\": { \"stub\": true } } }" | ||
} | ||
, { "method" : "put" | ||
, "path" : "/multipart_insert/mydoc" | ||
, "body" : "*" | ||
, "status" : 201 | ||
, "response" : "{\"ok\": true, \"id\": \"mydoc\", \"rev\": \"2-921bd51\"" | ||
} | ||
, { "path" : "/multipart_insert/mydoc" | ||
, "status" : 200 | ||
, "response" : "{\"_id\": \"mydoc\", \"_rev\": \"2-921bd51\", \"_attachments\": { \"one\": { \"stub\": true }, \"two\": { \"stub\": true } } }" | ||
} | ||
, { "method" : "put" | ||
, "path" : "/multipart_insert/otherdoc" | ||
, "body" : "*" | ||
, "status" : 201 | ||
, "response" : "{\"ok\": true, \"id\": \"foobar\", \"rev\": \"1-921bd51\" }" | ||
} | ||
, { "method" : "delete" | ||
, "path" : "/multipart_insert" | ||
, "status" : 200 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
] |
[ | ||
{ "path" : "/" | ||
{ "method" : "put" | ||
, "path" : "/shared_config" | ||
, "status" : 201 | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
, { "path" : "/" | ||
, "response" : "{\"ok\": true, \"version\": \"1.1.0\"}" | ||
@@ -30,3 +35,9 @@ } | ||
, {"path": "/_all_dbs", "response": "{}"} | ||
, { "path" : "/_all_dbs" | ||
, "response" : "{}" | ||
} | ||
, { "method" : "delete" | ||
, "path" : "/shared_config" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
] |
@@ -5,3 +5,3 @@ [ | ||
, "status" : 201 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
@@ -38,4 +38,4 @@ , { "path" : "/_config/admins/admin" | ||
, "path" : "/shared_cookie" | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
] |
@@ -5,16 +5,4 @@ [ | ||
, "status" : 201 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
, { "method" : "put" | ||
, "status" : 201 | ||
, "path" : "/shared_error/foobaz" | ||
, "body" : "{\"foo\":\"baz\"}" | ||
, "response" : "{\"ok\":true,\"id\":\"foobaz\",\"rev\":\"1-611488\"}" | ||
} | ||
, { "method" : "put" | ||
, "status" : 409 | ||
, "path" : "/shared_error/foobaz" | ||
, "body" : "{\"foo\":\"bar\"}" | ||
, "response" : "{\"error\":\"conflict\",\"reason\":\"Document update conflict.\"}" | ||
} | ||
, { "path" : "/" | ||
@@ -26,8 +14,8 @@ , "response" : "{\"ok\": true, \"version\": \"1.1.0\"}" | ||
, "status" : 404 | ||
, "response" : "{\"error\":\"not_found\",\"reason\":\"missing\"}" | ||
, "response" : "{\"error\":\"not_found\",\"reason\":\"missing\"}" | ||
} | ||
, { "method" : "delete" | ||
, "path" : "/shared_error" | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
] | ||
] |
@@ -5,3 +5,3 @@ [ | ||
, "status" : 201 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
@@ -28,4 +28,4 @@ , { "method" : "put" | ||
, "status" : 200 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
] | ||
] |
[ | ||
{ "method" : "put" | ||
{ "method" : "delete" | ||
, "path" : "/mydb" | ||
, "status" : 201 | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
@@ -11,6 +10,11 @@ , { "method" : "get" | ||
} | ||
, { "method" : "put" | ||
, "path" : "/mydb" | ||
, "status" : 201 | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
, { "method" : "delete" | ||
, "path" : "/mydb" | ||
, "response" : "{ \"ok\": true }" | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances 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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
257824
135
5713
0
1137
9
5
9
1
1
+ Addeddebug@^2.0.0
+ Addeddebug@2.6.9(transitive)
+ Addederrs@0.3.2(transitive)
+ Addedms@2.0.0(transitive)
+ Addedpsl@1.10.0(transitive)
+ Addedunderscore@1.13.7(transitive)
- Removedasn1@0.1.11(transitive)
- Removedassert-plus@0.1.5(transitive)
- Removedasync@0.9.2(transitive)
- Removedaws-sign2@0.5.0(transitive)
- Removedboom@0.4.2(transitive)
- Removedcombined-stream@0.0.7(transitive)
- Removedcryptiles@0.2.2(transitive)
- Removedctype@0.5.3(transitive)
- Removeddelayed-stream@0.0.5(transitive)
- Removederrs@0.2.4(transitive)
- Removedforever-agent@0.5.2(transitive)
- Removedform-data@0.1.4(transitive)
- Removedhawk@1.0.0(transitive)
- Removedhoek@0.9.1(transitive)
- Removedhttp-signature@0.10.1(transitive)
- Removedmime@1.2.11(transitive)
- Removednode-uuid@1.4.8(transitive)
- Removedoauth-sign@0.3.0(transitive)
- Removedpsl@1.13.0(transitive)
- Removedqs@0.6.6(transitive)
- Removedrequest@2.33.0(transitive)
- Removedsntp@0.2.4(transitive)
- Removedtunnel-agent@0.3.0(transitive)
- Removedunderscore@1.5.2(transitive)
Updatederrs@^0.3.0
Updatedfollow@^0.11.4
Updatedrequest@^2.53.0
Updatedunderscore@^1.7.0