Socket
Socket
Sign inDemoInstall

db-delivery

Package Overview
Dependencies
128
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.4 to 0.7.5

src/mysql-conection.js

7

package.json
{
"name": "db-delivery",
"version": "0.7.4",
"version": "0.7.5",
"description": "Micro node module for working with sqlite and mysql.",

@@ -17,8 +17,9 @@ "main": "index.js",

"dependencies": {
"sqlite": "^4.0.14",
"mysql": "^2.18.1",
"sqlite": "^4.0.17",
"sqlite3": "^5.0.0"
},
"devDependencies": {
"jest": "^26.4.2"
"jest": "^26.6.3"
}
}

@@ -18,3 +18,8 @@ class DB {

// ToDo implement the mysql connection method
createMysqlConnection(params) { }
createMysqlConnection(options) {
// console.log(options);
let MysqlConnection = require('./mysql-conection');
return new MysqlConnection(options);
}
}

@@ -21,0 +26,0 @@

@@ -28,2 +28,3 @@ class Query {

values(vals) {
if (!Array.isArray(vals)) throw new Error('Expected an Array object as a parameter not ' + typeof vals);
this.query += `VALUES (`;

@@ -39,2 +40,23 @@ vals.forEach(val => {

update(table) {
this.query = `UPDATE ${table} `;
return this;
}
set(columns, values) {
if (!Array.isArray(columns) || !Array.isArray(values)) {
throw new Error(`Type error Expected two parameters of arrays found ${typeof columns} and ${typeof values}`);
}
this.query += 'SET ';
for (let i = 0; i < columns.length; i++) {
this.query += `${columns[i]}=?`;
this.params.push(values[i]);
if (i < columns.length - 1) {
this.query += ', ';
}
this.query += ' ';
}
return this;
}
where(column, operator, criteria) {

@@ -87,4 +109,12 @@ this.query += `WHERE ${column} ${operator.toUpperCase()} ? `;

orderBy(column) {
orderBy(column, type = null) {
this.query += `ORDER BY ${column}`;
switch (type) {
case 'a':
this.query += ` ASC`;
break;
case 'd':
this.query += ` DESC`;
break;
}
return this;

@@ -91,0 +121,0 @@ }

@@ -74,4 +74,16 @@ const fs = require('fs');

}
updateRecord(sql, params) {
return new Promise((resolve, reject) => {
this.conn.run(sql, params, function (err) {
if (err) {
reject(err);
} else {
resolve(this.changes);
}
})
});
}
}
module.exports = SqliteConnection;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc