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

couchdb-client

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

couchdb-client - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

.travs.yml

259

index.js

@@ -5,161 +5,162 @@ /*jslint node:true*/

var CouchDBClient = function (options) {
this.options = {};
Object.assign(this.options, options, {
host: '127.0.0.1',
port: '5984'
});
this.place = 'http://' + this.options.host + ':' + this.options.port;
this.options = {};
Object.assign(this.options, options, {
host: '127.0.0.1',
port: '5984'
});
this.place = 'http://' + this.options.host + ':' + this.options.port;
};
function d(name, obj) {
CouchDBClient.prototype[name] = obj;
CouchDBClient.prototype[name] = obj;
}
d('welcome', function (cb) {
if (!cb) {
throw new Error('No callback supplied!');
}
request(this.place, function (error, response, data) {
if (response.statusCode === 200) {
cb(null, data);
} else {
cb(error || data);
if (!cb) {
throw new Error('No callback supplied!');
}
});
request(this.place, function (error, response, data) {
if (response.statusCode === 200) {
cb(null, data);
} else {
cb(error || data);
}
});
});
d('getUUIDs', function (num, cb) {
num = num || 1;
request(this.place + '/_uuids?count=' + num, function (error, response, data) {
data = JSON.parse(data);
if (response.statusCode === 200) {
if (num === 1) {
cb(null, data.uuids[0]);
} else {
cb(null, data.uuids);
}
} else {
cb(error || data);
}
});
num = num || 1;
request(this.place + '/_uuids?count=' + num, function (error, response, data) {
data = JSON.parse(data);
if (response.statusCode === 200) {
if (num === 1) {
cb(null, data.uuids[0]);
} else {
cb(null, data.uuids);
}
} else {
cb(error || data);
}
});
});
d('createDB', function (name, cb) {
request.put(this.place + '/' + name, function (error, response, data) {
data = JSON.parse(data);
if (response.statusCode === 201) {
cb(null, data);
} else {
cb(error || data);
}
});
request.put(this.place + '/' + name, function (error, response, data) {
data = JSON.parse(data);
if (response.statusCode === 201) {
cb(null, data);
} else {
cb(error || data);
}
});
});
d('getDB', function (name, cb) {
request(this.place + '/' + name, function (error, response, data) {
data = JSON.parse(data);
if (response.statusCode === 200) {
cb(null, data);
} else {
cb(error || data);
}
});
request(this.place + '/' + name, function (error, response, data) {
data = JSON.parse(data);
if (response.statusCode === 200) {
cb(null, data);
} else {
cb(error || data);
}
});
});
d('deleteDB', function (name, cb) {
request['delete'](this.place + '/' + name, function (error, response, data) {
data = JSON.parse(data);
if (response.statusCode === 200) {
cb(null, data);
} else {
cb(error || data);
}
});
request['delete'](this.place + '/' + name, function (error, response, data) {
data = JSON.parse(data);
if (response.statusCode === 200) {
cb(null, data);
} else {
cb(error || data);
}
});
});
d('addDoc', function (name, id, data, rev, cb) {
if (typeof rev === 'function') {
cb = rev;
rev = null;
}
if (!cb) {
throw new Error('Callback must be a function');
}
request.put(this.place + '/' + name + '/' + id + (rev ? '?rev=' + rev : ''), {body: JSON.stringify(data)}, function (error, response, data) {
data = JSON.parse(data);
if (response.statusCode === 201) {
cb(null, data);
} else {
cb(error || data);
if (typeof rev === 'function') {
cb = rev;
rev = null;
}
});
if (!cb) {
throw new Error('Callback must be a function');
}
request.put(this.place + '/' + name + '/' + id + (rev ? '?rev=' + rev : ''), {body: JSON.stringify(data)}, function (error, response, data) {
data = JSON.parse(data);
if (response.statusCode === 201) {
cb(null, data);
} else {
cb(error || data);
}
});
});
d('getDoc', function (name, id, cb) {
if (!cb) {
throw new Error('Callback must be a function');
}
request(this.place + '/' + name + '/' + id, function (error, response, data) {
data = JSON.parse(data);
var rev = '_' + 'rev';
data.rev = data[rev];
if (response.statusCode === 200) {
cb(null, data);
} else {
cb(error || data);
if (!cb) {
throw new Error('Callback must be a function');
}
});
request(this.place + '/' + name + '/' + id, function (error, response, data) {
data = JSON.parse(data);
var rev = '_' + 'rev';
data.rev = data[rev];
if (response.statusCode === 200) {
cb(null, data);
} else {
cb(error || data);
}
});
});
d('deleteDoc', function (name, id, rev, cb) {
if (!cb) {
throw new Error('Callback must be a function');
}
request.del(this.place + '/' + name + '/' + id + '?rev=' + rev, function (error, response, data) {
data = JSON.parse(data);
if (response.statusCode === 200) {
cb(null, data);
} else {
cb(error || data);
if (!cb) {
throw new Error('Callback must be a function');
}
});
request.del(this.place + '/' + name + '/' + id + '?rev=' + rev, function (error, response, data) {
data = JSON.parse(data);
if (response.statusCode === 200) {
cb(null, data);
} else {
cb(error || data);
}
});
});
d('addView', function (name, id, obj, rev, cb) {
if (typeof rev === 'function') {
cb = rev;
rev = null;
}
var view = {},
did = '_' + 'id';
view[did] = '_design/' + id;
view.views = obj;
request.put(this.place + '/' + name + '/_design/' + id + (rev ? '?rev=' + rev : ''), {body: JSON.stringify(view)}, function (error, response, data) {
if (error) {
return cb(error);
if (typeof rev === 'function') {
cb = rev;
rev = null;
}
data = JSON.parse(data);
if (response.statusCode.toString().indexOf('20') === 0) {
cb(null, data);
} else {
cb(error || data);
}
});
var view = {},
did = '_' + 'id',
i;
view[did] = '_design/' + id;
view.views = obj;
request.put(this.place + '/' + name + '/_design/' + id + (rev ? '?rev=' + rev : ''), {body: JSON.stringify(view)}, function (error, response, data) {
if (error) {
return cb(error);
}
data = JSON.parse(data);
if (response.statusCode.toString().indexOf('20') === 0) {
cb(null, data);
} else {
cb(error || data);
}
});
});
d('deleteView', function (name, id, rev, cb) {
request.del(this.place + '/' + name + '/_design/' + id + '?rev=' + rev, function (error, response, data) {
if (error) {
return cb(error);
}
data = JSON.parse(data);
if (response.statusCode === 200) {
cb(null, data);
} else {
cb(error || data);
}
});
request.del(this.place + '/' + name + '/_design/' + id + '?rev=' + rev, function (error, response, data) {
if (error) {
return cb(error);
}
data = JSON.parse(data);
if (response.statusCode === 200) {
cb(null, data);
} else {
cb(error || data);
}
});
});
d('useView', function (name, id, view, key, cb) {
request(this.place + '/' + name + '/_design/' + id + '/_view/' + view + (key ? '?key="' + key + '"' : ''), function (error, response, data) {
if (error) {
return cb(error);
}
data = JSON.parse(data);
if (response.statusCode === 200) {
cb(null, data);
} else {
cb(error || data);
}
});
request(this.place + '/' + name + '/_design/' + id + '/_view/' + view + (key ? '?key="' + key + '"' : ''), function (error, response, data) {
if (error) {
return cb(error);
}
data = JSON.parse(data);
if (response.statusCode === 200) {
cb(null, data);
} else {
cb(error || data);
}
});
});
module.exports = CouchDBClient;

@@ -22,3 +22,3 @@ {

"email": "legodudejb@gmail.com",
"name": "legodude"
"name": "JDB"
}

@@ -31,3 +31,3 @@ ],

"tonicTest": "https://tonicdev.com/npm/couchdb-client",
"version": "1.0.10",
"version": "1.0.11",
"repository": {

@@ -34,0 +34,0 @@ "type": "git",

@@ -1,2 +0,2 @@

# CouchDBClient
# CouchDBClient [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]

@@ -185,2 +185,10 @@ ## Table of Contents

## Lisence
MIT
MIT
[npm-image]: https://badge.fury.io/js/online-game.svg
[npm-url]: https://npmjs.org/package/online-game
[travis-image]: https://travis-ci.org/legodude17/online-game.svg?branch=master
[travis-url]: https://travis-ci.org/legodude17/online-game
[daviddm-image]: https://david-dm.org/legodude17/online-game.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/legodude17/online-game
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