couchdb-services
Advanced tools
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; |
{ | ||
"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" | ||
} | ||
} |
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
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
6167
134
0
2
1
+ Addedmodule-connector@^1.0.9
+ Addednano@^9.0.1
+ Added@types/tough-cookie@4.0.5(transitive)
+ Addedaxios@0.21.4(transitive)
+ Addedaxios-cookiejar-support@1.0.1(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.0.0(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.6(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedis-redirect@1.0.0(transitive)
+ Addedmath-intrinsics@1.0.0(transitive)
+ Addedmodule-connector@1.0.9(transitive)
+ Addednano@9.0.5(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedpify@5.0.0(transitive)
+ Addedpsl@1.15.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@6.13.1(transitive)
+ Addedquerystringify@2.2.0(transitive)
+ Addedrequires-port@1.0.0(transitive)
+ Addedside-channel@1.1.0(transitive)
+ Addedside-channel-list@1.0.0(transitive)
+ Addedside-channel-map@1.0.1(transitive)
+ Addedside-channel-weakmap@1.0.2(transitive)
+ Addedtough-cookie@4.1.4(transitive)
+ Addeduniversalify@0.2.0(transitive)
+ Addedurl-parse@1.5.10(transitive)