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

@squill/mysql-5.7

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@squill/mysql-5.7

A MySQL 5.7 query-builder/ORM

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

At the moment, written with MySQL 5.7.26 in mind.

This is a MySQL 5.7 adapter for @squill/squill


TODO

  • Detailed usage instructions
import * as squill from "@squill/squill";
import * as mysql from "@squill/mysql-5.7";

const myTable = squill.table("myTable")
    .addColumns({
        myTableId : squill.dtBigIntSigned(),
        description : squill.dtVarChar(1024),
    })
    .setAutoIncrement(columns => columns.myTableId);

const pool = new mysql.Pool({
    host      : /*Some MySQL_HOST*/,
    database  : /*Some MYSQL_DATABASE*/,
    user      : /*Some MYSQL_USERNAME*/,
    password  : /*Some MYSQL_PASSWORD*/,
    charset   : mysql.CharSet.utf8mb4,
});

pool
    .acquire(connection => myTable
        .whereEqPrimaryKey({
            myTableId : 1337n,
        })
        .fetchOne(connection)
    )
    .then(
        (row) => {
            console.log(row.myTableId);
            console.log(row.description);
        },
        (err) => {
            if (squill.isSqlError(err)) {
                //Probably some error related to executing a SQL query
                //Maybe a RowNotFoundError
            } else {
                //Probably some other error
            }
        }
    );

/**
 * Build a query that may be used later.
 */
const myQuery = squill.from(myTable)
    .select(columns => [
        columns.myTableId
        squill.concat(
            "Description: ",
            columns.description
        ).as("labeledDescription"),
    ]);

pool
    .acquire(connection => myQuery
        .whereEqPrimaryKey(
            tables => tables.myTable,
            {
                myTableId : 1337n,
            }
        )
        .fetchOne(connection)
    )
    .then(
        (row) => {
            console.log(row.myTableId);
            console.log(row.labeledDescription);
        },
        (err) => {
            if (squill.isSqlError(err)) {
                //Probably some error related to executing a SQL query
                //Maybe a RowNotFoundError
            } else {
                //Probably some other error
            }
        }
    );

FAQs

Package last updated on 07 Mar 2020

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

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