Comparing version 0.0.1 to 0.0.2
27
cot.js
@@ -25,3 +25,2 @@ /* | ||
var http = require('http'); | ||
var querystring = require('querystring'); | ||
@@ -40,5 +39,12 @@ | ||
function Cot(port, host) { | ||
this.port = port; | ||
this.host = host; | ||
function Cot(opts) { | ||
this.port = opts.port; | ||
this.hostname = opts.hostname; | ||
this.auth = opts.auth; | ||
this.ssl = opts.ssl; | ||
this.http = opts.ssl ? require('https') : require('http'); | ||
this.hostHeader = this.hostname; | ||
if ((!this.ssl && this.port !== 80) || (this.ssl && this.port !== 443)) { | ||
this.hostHeader += ':' + this.port; | ||
} | ||
} | ||
@@ -49,4 +55,5 @@ | ||
var opts = { | ||
host: this.host, | ||
hostname: this.hostname, | ||
port: this.port, | ||
auth: this.auth, | ||
path: path, | ||
@@ -57,4 +64,4 @@ method: method, | ||
opts.headers.host = this.host; | ||
opts.headers.host = this.hostHeader; | ||
return opts; | ||
@@ -104,3 +111,3 @@ }, | ||
var request = http.request(this.reqOpts('GET', path, headers)); | ||
var request = this.http.request(this.reqOpts('GET', path, headers)); | ||
this.processResponse(request, next); | ||
@@ -115,3 +122,3 @@ }, | ||
var request = http.request(this.reqOpts('DELETE', path, headers)); | ||
var request = this.http.request(this.reqOpts('DELETE', path, headers)); | ||
this.processResponse(request, next); | ||
@@ -134,3 +141,3 @@ }, | ||
var request = http.request(this.reqOpts(which, path, headers)); | ||
var request = this.http.request(this.reqOpts(which, path, headers)); | ||
request.write(body); | ||
@@ -137,0 +144,0 @@ this.processResponse(request, next); |
@@ -5,3 +5,3 @@ { | ||
"keywords": ["couch", "couchdb"], | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"main": "cot", | ||
@@ -8,0 +8,0 @@ "dependencies": {}, |
@@ -6,3 +6,3 @@ # What is Cot? # | ||
var Cot = require('cot'); | ||
var cot = new Cot(5984, 'localhost'); | ||
var cot = new Cot({port: 5984, hostname: 'localhost'}); | ||
var db = cot.db('my-db'); | ||
@@ -54,6 +54,18 @@ | ||
## cot = new Cot(port, host) ## | ||
## cot = new Cot(opts) ## | ||
`opts` must contain the following keys: | ||
- `port`: the port number of your couchdb server | ||
- `hostname`: the hostname of your couchdb server | ||
`opts` may contain the following keys: | ||
- `ssl`: if set to true, Cot will use https | ||
- `auth`: may be set to a string in the format 'username:password' for basic auth | ||
## db = cot.db(dbName) ## | ||
Returns an object representing the specified database. | ||
## db.info(next(err, info)) ## | ||
@@ -111,3 +123,3 @@ | ||
Refer to the CouchDB API documentation for their meanings. | ||
For more information, refer to http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options | ||
@@ -128,3 +140,16 @@ ## db.allDocs(query, next(err, response)) | ||
Posts multiple updates to the database in one request. `docs` should be an array of documents. `allOrNothing` should be a boolean. See http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API for more information. | ||
## db.changes(query, next) | ||
Queries the changes feed given the specified query. `query` may contain the following keys: | ||
- `filter`: filter function to use | ||
- `include_docs`: if true, results will contain entire document | ||
- `limit`: the maximum number of change rows this query should return | ||
- `since`: results will start immediately after the sequence number provided here | ||
- `longpoll`: if true, query will send feed=longpoll | ||
- `timeout`: timeout in milliseconds for logpoll queries | ||
For more information about the CouchDB changes feed, see http://wiki.apache.org/couchdb/HTTP_database_API#Changes | ||
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
18146
5
448
152
2