Socket
Socket
Sign inDemoInstall

mysql-format

Package Overview
Dependencies
323
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mysql-format

Simplified MySQL Promises Package Coded In TypeScript


Version published
Maintainers
1
Created

Readme

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

Last updated on 30 Jan 2022

Did you know?

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

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