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

jeefo-mysql

Package Overview
Dependencies
Maintainers
2
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jeefo-mysql - npm Package Compare versions

Comparing version 0.0.27 to 0.0.28

27

index.js
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : connect.js
* File Name : index.js
* Created at : 2021-10-09
* Updated at : 2021-10-09
* Updated at : 2021-10-10
* Author : jeefo

@@ -77,3 +77,4 @@ * Purpose :

async select(where, options = {}) {
const fields = options.fields ? options.fields.join(", ") : '*';
let {fields} = options;
fields = fields ? this.prepare_fields(fields) : '*';

@@ -147,2 +148,7 @@ where = where ? ` WHERE ${this.prepare_where(where)}` : '';

prepare_fields(fields) {
if (is.string(fields)) fields = [fields];
return fields.join(", ");
}
prepare_where(where) {

@@ -176,6 +182,2 @@ return Object.keys(where).map(key => {

async find(where, options) {
return await this.select(where, options);
}
async reset() {

@@ -196,12 +198,5 @@ const tbl = this.table_name;

async delete_all() {
await this.delete();
}
get_all() { return this.select(); }
delete_all() { return this.delete(); }
async get_all() {
const query = `SELECT * FROM ${this.table_name};`;
const {results} = await this.exec(query);
return results;
}
async total() {

@@ -208,0 +203,0 @@ const query = `SELECT COUNT(*) as total FROM ${this.table_name};`;

{
"name": "jeefo-mysql",
"version": "0.0.27",
"version": "0.0.28",
"description": "Very simple MySQL connection instances for each table. I had annoyed enough for MySQL Deadlocks.",

@@ -5,0 +5,0 @@ "main": "index.js",

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : test.js
* Created at : 2021-10-09
* Updated at : 2021-10-09
* Updated at : 2021-10-10
* Author : jeefo

@@ -18,4 +18,12 @@ * Purpose :

const mysql = require("./connect.js");
const mysql = require("./index.js");
function assert(condition, message) {
if (condition) {
console.log(`ASSERT '${message}' passed.`);
} else {
throw new Error(`ASSERT '${message}' failed.`);
}
}
(async () => {

@@ -36,9 +44,8 @@ await mysql.config_load(`${process.env.HOME}/configs/database.json`);

let total = await process_db.total();
console.log(results);
console.log(total);
assert(results.length === total, "results.length === total");
await process_db.delete_all();
total = await process_db.total();
console.log(total);
assert(total === 0, "total length = 0");
})().catch(console.error.bind(console));
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