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

couchdb-services

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

couchdb-services - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

168

index.js

@@ -1,3 +0,165 @@

module.exports = (str) => {
return `💩${str}💩`;
}
let moduleConnector = require("module-connector");
let nano = require('nano');
class CouchDBServices {
constructor(objectModel) {
this.dbType = objectModel.dbType;
this.dbPass = objectModel.dbPass;
this.dbUser = objectModel.dbUser;
this.dbHost = objectModel.dbHost;
this.dbPort = objectModel.dbPort;
this.dbName = objectModel.dbName;
this.dbEndpoint = objectModel.dbEndpoint;
this.dbSchema = objectModel.dbSchema;
this.dbTable = objectModel.dbTable;
this.conString = [
`DATABASE=${this.dbName}`,
`HOSTNAME=${this.dbHost}`,
`UID=${this.dbUser}`,
`PWD=${this.dbPass}`,
`PORT=${this.dbPort}`,
`PROTOCOL=TCPIP`,
].join(";");
};
}
CouchDBServices.prototype.createDabase = async(strDatabaseName) => {
let output = new moduleConnector();
try {
let couchInstance = nano(this.dbEndpoint);
let createDB = await couchInstance.db.create(strDatabaseName);
output.ok(createDB);
} catch (error) {
console.error(error);
} finally {
return output;
}
};
CouchDBServices.prototype.get = async(idDoc) => {
let output = new moduleConnector();
try {
let couchInstance = nano(this.dbEndpoint);
let couchDB = couchInstance.use(this.dbTable);
let doc = await couchDB.get(idDoc);
output.ok(doc);
} catch (error) {
console.error(error);
} finally {
return output;
}
};
CouchDBServices.prototype.getAll = async(arrayQuery = { mangoQuery: { selector: {}, limit: 1000 } }, arrayIndex = false) => {
let output = new moduleConnector();
try {
let couchInstance = nano(this.dbEndpoint);
let couchDB = couchInstance.use(this.dbTable);
if (arrayIndex) {
await couchDB.createIndex(arrayIndex);
}
var arrayDocs = await couchDB.find(arrayQuery.mangoQuery)
output.ok(arrayDocs, "couch_getAll_response");
} catch (error) {
console.error(error);
} finally {
return output;
}
};
CouchDBServices.prototype.create = async(newDoc) => {
let output = new moduleConnector();
try {
let couchInstance = nano(this.dbEndpoint);
let couchDB = couchInstance.use(this.dbTable);
var postNewDoc = await couchDB.insert(newDoc);
output.ok(postNewDoc, "couch_update_response");
} catch (error) {
console.error(error);
} finally {
return output;
}
};
CouchDBServices.prototype.update = async(doc) => {
let output = new moduleConnector();
try {
let couchInstance = nano(this.dbEndpoint);
let couchDB = couchInstance.use(this.dbTable);
let postNewDoc = await couchDB.insert(doc);
output.ok(postNewDoc, "couch_update_response");
} catch (error) {
console.error(error);
} finally {
return output;
}
};
CouchDBServices.prototype.delete = async(doc) => {
let output = new moduleConnector();
try {
let couchInstance = nano(this.dbEndpoint);
let couchDB = couchInstance.use(this.dbTable);
let postNewDoc = await couchDB.destroy(doc._id, doc._rev);
output.ok(postNewDoc, "couch_delete_response");
} catch (error) {
console.error(error);
} finally {
return output;
}
};
CouchDBServices.prototype.view = async(designname, viewname, params) => {
let output = new moduleConnector();
try {
let couchInstance = nano(this.dbEndpoint);
let couchDB = couchInstance.use(this.dbTable);
let doc = await couchDB.view(designname, viewname, params);
if (doc && doc.rows && doc.rows.length) {
let docs = doc.rows;
output.ok({ docs });
} else {
output.ok(doc);
}
} catch (error) {
console.error(error);
} finally {
return output;
}
};
CouchDBServices.prototype.bulk = async(arrayDocs) => {
let output = new moduleConnector();
try {
let couchInstance = nano(this.dbEndpoint);
let couchDB = couchInstance.use(this.dbTable);
let postNewDoc = await couchDB.bulk({ docs: arrayDocs });
output.ok(postNewDoc, "couch_bulk_response");
} catch (error) {
console.error(error);
} finally {
return output;
}
};
module.exports = CouchDBServices;

8

package.json
{
"name": "couchdb-services",
"version": "1.0.0",
"version": "1.0.1",
"description": "",

@@ -18,3 +18,7 @@ "main": "index.js",

},
"homepage": "https://github.com/jhonnattan123/couchdb-services#readme"
"homepage": "https://github.com/jhonnattan123/couchdb-services#readme",
"dependencies": {
"module-connector": "^1.0.9",
"nano": "^9.0.1"
}
}
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