@dpapejs/emysql
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

emysql

npm npm NPM

介绍

🛠️ 基于 mysql 基础二次封装,追求打造简单、好用的 mysql-ORM 库.

安装教程

npm i @dpapejs/emysql@latest -S

使用说明

import emysql from '@dpapejs/emysql' // 引用库
const mysql = new emysql() // 函数实例化
// 创建表结构
await mysql.execCreateTable([
  {
    tableName: 'create_table',
    columns: [
      {
        name: 'id',
        dataType: 'INT',
        primaryKey: true,
        autoIncrement: true,
        comments: '主键id'
      },
      {
        name: 'name',
        dataType: 'VARCHAR',
        length: 45,
        notNull: true,
        comments: '名称'
      },
      {
        name: 'create_at',
        dataType: 'DATETIME',
        notNull: true,
        comments: '创建时间'
      }
    ]
  }
])
// 插入数据
const now = new Date()
await mysql.execDataChange('INSERT', 'create_table', {
  keys: ['name', 'create_at'],
  values: ['test', now]
})
// 查询数据
const list = await mysql.execQuery('query_test', {
  keys: [{ field: 'name' }, { field: 'id' }],
  where: [{ field: 'id' }],
  values: [1]
})
console.log(list) // [{id:1,name:"test"}]

Package Sidebar

Install

npm i @dpapejs/emysql

Weekly Downloads

75

Version

1.0.3

License

MIT

Unpacked Size

28.9 MB

Total Files

869

Last publish

Collaborators

  • yang2015damon