couchdb-client
Advanced tools
Comparing version 1.0.7 to 1.0.8
{ | ||
"name": "couchdb-client", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "A simple couchdb client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -81,2 +81,3 @@ # CouchDBClient | ||
```js | ||
var rev; | ||
client.getDB('foo', function (err, data) { | ||
@@ -86,2 +87,3 @@ if (err) { | ||
} else { | ||
rev = data.rev; | ||
console.log(data); | ||
@@ -95,3 +97,3 @@ } | ||
```js | ||
client.deleteDB('foo', function (err, data) { | ||
client.deleteDB('foo', rev, function (err, data) { | ||
if (err) { | ||
@@ -103,15 +105,72 @@ console.error(err); | ||
}); | ||
``` | ||
## #addDoc(name, id, [rev], callback) | ||
Adds a doc, could also be used to update a doc. | ||
```js | ||
var rev2; | ||
client.addDoc('foo', 'bar', {hi: true, bye false}, function (err, data) { | ||
if (err) { | ||
console.error(err); | ||
} else { | ||
rev2 = data.rev; | ||
console.log(data); | ||
} | ||
}); | ||
``` | ||
## #getDoc(name, id, callback) | ||
Gets a document from the database. | ||
```js | ||
client.getDoc('foo', 'bar', function (err, data) { | ||
if (err) { | ||
console.error(err); | ||
} else { | ||
console.log(data); | ||
} | ||
}); | ||
``` | ||
## #deleteDoc(name, id, rev, callback) | ||
Deletes a document. | ||
```js | ||
client.deleteDoc('foo', 'bar', rev, function (err, data) { | ||
if (err) { | ||
console.error(err); | ||
} else { | ||
console.log(data); | ||
} | ||
}); | ||
``` | ||
## #addView(name, id, obj, callback) | ||
Adds or updates a view. | ||
```js | ||
client.addView('test', 'stuff', {all: {map: "function (doc){emit(null,doc)}"}}, function (err, data) { | ||
if (err) { | ||
console.error(err); | ||
} else { | ||
rev = data.rev; | ||
console.log(data); | ||
} | ||
}); | ||
``` | ||
## #deleteView(name, id, rev, callback) | ||
Deletes a view. | ||
```js | ||
client.deleteView('test', 'stuff', rev, function (err, data) { | ||
if (err) { | ||
console.error(err); | ||
} else { | ||
console.log(data); | ||
} | ||
}); | ||
``` | ||
## #useView(name, id, view, [key,] callback) | ||
Uses a view with the specified key. | ||
```js | ||
client.useView('test', 'stuff', 'all', 'hi', function (err, data) { | ||
if (err) { | ||
console.error(err); | ||
} else { | ||
console.log(data); | ||
} | ||
}); | ||
``` | ||
## Test | ||
@@ -118,0 +177,0 @@ ```bash |
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
15600
178