🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

mysql-format

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

mysql-format

Simplified MySQL Promises Package Coded In TypeScript

1.0.18
unpublished
latest
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

MySQL Format

Simplified MySQL Promises Package Coded In TypeScript

Installation

npm

  npm i mysql-format

Functions

TypeUsage
arrayResultsgetAll()
arrayResultsgetByFiled({...FilterFiled})
jsonResultsgetOneByFiled({...FilterFiled})
boolResultscreateOne({...NewField},customQuery?, ...args)
boolResultsupdateOne({...FilterFiled}, {...NewFiled}, customQuery?, ...args)
boolResultsdeleteOne({...FilterFiled})
boolResultsdeleteAll()
evalResultsevalAsync("SQL QUERY", ...args)
callbackeval("SQL QUERY", (err, data)=> void, ...args)

Usage/Examples

import { Connection } from "mysql-format";

let connection = new Connection(
  {
    port: 3308,
    user: "username",
    password: "password",
    host: "localhost",
    database: "database",
  },
  {
    printErrors: false,
    throwErrors: true,
  }
);

async function Test() {
  let results = await db.evalAsync("SELECT * FROM quizServers");
  let parsed = JSON.parse(results.results[0].connections);
  const newJson: any[] = [];
  for (const i in parsed) {
    let data = parsed[i];
    if (!newJson.find((e) => e.id == data.id)) {
      newJson.push(data);
    }
  }
  newJson.push({
    id: 555,
    position: 8,
  });
  let data = await db.evalAsync(
    `UPDATE quizServers SET connections=? WHERE id="25"`,
    JSON.stringify(newJson.sort((a, b) => a.position - b.position))
  );
  console.log(data.results);
}

async function Test() {
  const model = db.useModel("accounts");
  let results = await model.getAll();
  console.log(results.results); // any[]
}

Author

  • @orjdev

License

ISC

FAQs

Package last updated on 30 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts