# emysql **Repository Path**: aiclouddigit/e-mysql ## Basic Information - **Project Name**: emysql - **Description**: 🛠️ Based on mysql basic secondary packaging, the pursuit of creating a simple and easy to use mysql-ORM library - **Primary Language**: TypeScript - **License**: MIT - **Default Branch**: master - **Homepage**: http://emysql.dpapejs.cn/ - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2024-05-23 - **Last Updated**: 2026-01-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # @aicblock/emysql ![npm](https://img.shields.io/npm/v/@aicblock/emysql) ![npm](https://img.shields.io/npm/dm/@aicblock/emysql) ![NPM](https://img.shields.io/npm/l/@aicblock/emysql) #### 介绍 🛠️ 基于 `mysql` 基础二次封装,追求打造简单、好用的 `mysql-ORM` 库. #### 安装教程 ```sh npm i @aicblock/emysql@latest -S ``` #### 使用说明 ```ts import emysql, { DefineTable } from '@aicblock/emysql' // 引用库 // 函数实例化 const mysql = new emysql({ password: '[database login password]', user: '[database login username]', database: 'database name' }) // 创建表结构 const createTable = DefineTable({ 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: '创建时间' } ] }) // 初始化数据库 await mysql.init() // 创建表 await mysql.table.create([createTable]) // 插入数据 const now = new Date() await mysql.change.insert({ t: createTable, params: { name: 'test', create_at: now } }) // 查询数据 const list = await mysql.query({ t: createTable, fields: ['name', 'id'], condition: { id: 1 } }) console.log(list) // [{id:1,name:"test"}] ```