Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nano

Package Overview
Dependencies
Maintainers
2
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nano - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

25

nano.js

@@ -564,16 +564,27 @@ /* minimal couch in node

* @param {doc_name:string:optional} document name
* @param {params:string:optional} additions to the querystring
*
* @see relax
*/
function insert_doc(doc,doc_name,callback) {
function insert_doc(doc,params,callback) {
var opts = {db: db_name, body: doc, method: "POST"};
if(doc_name) {
if(typeof doc_name === "function") {
callback = doc_name;
}
else {
opts.doc = doc_name;
if(typeof params === "function") {
callback = params;
params = {};
}
if(typeof params === "string") {
params = {doc_name: params};
}
if (params) {
if(params.doc_name) {
opts.doc = params.doc_name;
opts.method = "PUT";
delete params.doc_name;
}
opts.params = params;
}
return relax(opts,callback);

@@ -580,0 +591,0 @@ }

@@ -5,3 +5,3 @@ { "name" : "nano"

, "repository" : "git://github.com/dscape/nano"
, "version" : "3.2.0"
, "version" : "3.3.0"
, "author" : "Nuno Job <nunojobpinto@gmail.com> (http://nunojob.com)"

@@ -27,2 +27,3 @@ , "contributors" :

, "Clemens Stolle (https://github.com/klaemo)"
, "Jay Beavers <jay.beavers@microsoft.com> (http://jaybeavers.org)"
]

@@ -29,0 +30,0 @@ , "keywords" :

@@ -284,5 +284,5 @@ # nano

### db.insert(doc, [docname], [callback])
### db.insert(doc, [params], [callback])
inserts `doc` in the database with an optional `docname`.
inserts `doc` in the database with 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 `doc_name` is checked for defining the document name.

@@ -289,0 +289,0 @@ ``` js

@@ -6,2 +6,3 @@ var specify = require('specify')

, nock = helpers.nock
, rev
;

@@ -20,3 +21,4 @@

specify("doc_insert:simple", timeout, function (assert) {
db.insert({"foo": "baz"}, "foobaz", function (error, foo) {
db.insert({"foo": "baz"}, "foobaz", function (error, foo) {
rev = foo.rev;
assert.equal(error, undefined, "Should have stored foo");

@@ -28,5 +30,14 @@ assert.equal(foo.ok, true, "Response should be ok");

specify("doc_insert:params", timeout, function (assert) {
db.insert({"foo": "baz", _rev: rev}, {doc_name:"foobaz", new_edits:false},
function (error, foo) {
assert.equal(error, undefined, "Should have stored foo");
assert.equal(foo.ok, true, "Response should be ok");
assert.ok(foo.rev, "Response should have rev");
});
});
specify("doc_insert:functions", timeout, function (assert) {
db.insert({fn: function () { return true; },
fn2: "function () { return true; }"}, function (error, fns) {
fn2: "function () { return true; }"}, function (error, fns) {
assert.equal(error, undefined, "Should have stored foo");

@@ -33,0 +44,0 @@ assert.equal(fns.ok, true, "Response should be ok");

@@ -13,2 +13,8 @@ [

}
, { "method" : "put"
, "status" : 201
, "path" : "/doc_insert/foobaz?new_edits=false"
, "body" : "{\"foo\":\"baz\",\"_rev\":\"1-611488\"}"
, "response" : "{\"ok\":true,\"id\":\"foobaz\",\"rev\":\"2-123456\"}"
}
, { "method" : "post"

@@ -15,0 +21,0 @@ , "status" : 201

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc