Skip to main content

@8v/mysql@0.1.11

latest
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
23%
Published
a month ago (0.1.11)

Github Repo

Usage

#!/usr/bin/env bun

// import mysql from "./mod.js";

Code

mod.coffee

#!/usr/bin/env coffee

> mysql2/promise > createConnection

export default (option)=>
  conn = await createConnection(
    Object.assign(
      {
        # connectTimeout: The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10000)
        # connectTimeout: 10000
        rowsAsArray: true
        typeCast: (field, next)=>
          {type} = field
          if (
            not [32,512].includes(
              field.length
            ) and type == 'VAR_STRING'
          ) or type.endsWith('BLOB')
            return field.buffer().toString('utf8')
          return next()
      },
      option
    )
  )

  q = (
    sql
    arg...
  ) =>
    (
      await conn.query(
        sql
        arg
      )
    )[0]

  q0 = (
    sql
    arg...
  ) =>
    (await q(sql, ...arg))[0]

  q00 = (
    sql
    arg...
  ) =>
    r = await q0(sql, ...arg)
    if r
      return r[0]
    return

  {
    conn
    q
    q0
    q00
  }

About

About

This project is an open-source component of i18n.site ⋅ Internationalization Solution.

关于

本项目为 i18n.site ⋅ 国际化解决方案 的开源组件。

Add Package

deno add jsr:@8v/mysql

Import symbol

import * as mysql from "@8v/mysql";

---- OR ----

Import directly with a jsr specifier

import * as mysql from "jsr:@8v/mysql";

Add Package

npx jsr add @8v/mysql

Import symbol

import * as mysql from "@8v/mysql";

Add Package

yarn dlx jsr add @8v/mysql

Import symbol

import * as mysql from "@8v/mysql";

Add Package

pnpm dlx jsr add @8v/mysql

Import symbol

import * as mysql from "@8v/mysql";

Add Package

bunx jsr add @8v/mysql

Import symbol

import * as mysql from "@8v/mysql";