-
Notifications
You must be signed in to change notification settings - Fork 10
Database
Represents a CouchDB database. Like the Server
object, the methods here are largely administrative.
var couchdb = require("couchdb-api");
var db = couchdb().db("mydb");
This helper method is for generating a String
URL relative to the database. If path
is specified,
it will resolve that path relative to the server root. (therefore, beginning a path with /
will make
the resolved path relative to the server itself) path
can also be an Array:String
.
var base = db.url();
// => http://localhost:5984/mydb
var doc = db.url("mydoc");
// => http://localhost:5984/mydb/mydoc
var root = db.url("/");
// => http://localhost:5984/
This helper method creates and returns a new Document
object based on this Database
.
Both parameters are technically optional, see the Document API documentation for more information.
var doc = db.doc("mydoc");
This helper method creates and returns a new DesignDocument
object based on this Database
.
Both parameters are technically optional, see the Document API documentation for more information.
var ddoc = db.ddoc("myddoc");
This helper method creates and returns a new LocalDocument
object based on this Database
.
Both parameters are technically optional, see the Document API documentation for more information.
var ldoc = db.ldoc("myldoc");
PUT /{db}
CouchDB Documentation
Creates the database and returns the results.
db.create(function (err, results) {
// ...
});
DELETE /{db}
CouchDB Documentation
Deletes the database.
db.destroy(function (err, results) {
// ...
});
HEAD /{db}
CouchDB Documentation
Checks for the database's existence.
db.exists(function (err, exists) {
// ...
});
GET /{db}
CouchDB Documentation
Retrieves information about this database.
db.info(function (err, info) {
// ...
});