Skip to content
This repository has been archived by the owner on Jan 23, 2022. It is now read-only.
/ mysql.ts Public archive

A simple node.js MySQL wrapper made with TypeScript.

License

Notifications You must be signed in to change notification settings

casperiv0/mysql.ts

Repository files navigation

mysql.ts

npm size license maintained

A simple node.js MySQL wrapper made with TypeScript.

Installation

npm

npm i @casper124578/mysql.ts

Yarn

yarn add @casper124578/mysql.ts

Usage

import { createConnection } from "@casper124578/mysql.ts";

async function init() {
  const connection = await createConnection({
    /* options */
    /* see: https://github.com/mysqljs/mysql#connection-options */
  });

  // query something
  const results = await connection.query().select(["id", "name"]).from("books").exec();

  console.log(results);
}

TypeScript support

interface MyData {
  id: string;
  fist_name: string;
  last_name: string;
}

const connection = await createConnection({
  /* ... */
});

const books = await connection
  .query<MyData>()
  // will have types!
  .select(["last_name", "fist_name"])
  .from("books")
  // will have types!
  .where("last_name", "hello")
  // will have types!
  .order("last_name", "ASC")
  .exec();

This is not a full list of methods. Check the docs for a full list!

Documentation

Checkout the documentation here

More

Example

You view check an example here