Merge pull request #324 from magickang/master
Validate docName parameter to avoid db delete
diff --git a/README.md b/README.md
index 8ca9dd3..3bfbe57 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,7 @@
- [nano.db.replicate(source, target, [opts], [callback])](#nanodbreplicatesource-target-opts-callback)
- [nano.db.changes(name, [params], [callback])](#nanodbchangesname-params-callback)
- [nano.db.follow(name, [params], [callback])](#nanodbfollowname-params-callback)
+ - [nano.db.info([callback])](#nanodbinfocallback)
- [nano.use(name)](#nanousename)
- [nano.request(opts, [callback])](#nanorequestopts-callback)
- [nano.config](#nanoconfig)
@@ -300,6 +301,16 @@
});
```
+### nano.db.info([callback])
+
+gets database information.
+
+nano.db.info(function(err, body) {
+ if (!err) {
+ console.log('got database info'', body);
+ }
+});
+
### nano.use(name)
creates a scope where you operate inside `name`.
@@ -411,7 +422,7 @@
The `insert` function can also be used with the method signature `db.insert(doc,[callback])`, where the `doc` contains the `_id` field e.g.
~~~ js
-var alice = cloudant.use('alice')
+var alice = nano.use('alice')
alice.insert({ _id: 'myid', crazy: true }, function(err, body) {
if (!err)
console.log(body)
@@ -421,7 +432,7 @@
and also used to update an existing document, by including the `_rev` token in the document being saved:
~~~ js
-var alice = cloudant.use('alice')
+var alice = nano.use('alice')
alice.insert({ _id: 'myid', _rev: '1-23202479633c2b380f79507a776743d5', crazy: false }, function(err, body) {
if (!err)
console.log(body)
diff --git a/lib/nano.js b/lib/nano.js
index 227ebbd..dc819ac 100644
--- a/lib/nano.js
+++ b/lib/nano.js
@@ -60,7 +60,7 @@
return db;
}
}
-
+
function scrub(str) {
if (str) {
str = str.replace(/\/\/(.*)@/,"//XXXXXX:XXXXXX@");
@@ -472,6 +472,7 @@
qs = {};
}
+ qs = qs || {};
qs['include_docs'] = true;
return relax({