UNPKG

@dpapejs/emysql

Version:

🛠️ Based on the basic secondary package of `mysql`, the pursuit of creating a simple and easy to use `mysql-ORM` library.

69 lines (61 loc) 1.46 kB
# @dpapejs/emysql ![npm](https://img.shields.io/npm/v/@dpapejs/emysql) ![npm](https://img.shields.io/npm/dm/@dpapejs/emysql) ![NPM](https://img.shields.io/npm/l/@dpapejs/emysql) #### Description 🛠️ Based on the basic secondary package of `mysql`, the pursuit of creating a simple and easy to use `mysql-ORM` library. #### Installation ```sh npm i @dpapejs/emysql@latest -S ``` #### Instructions ```ts import emysql from '@dpapejs/emysql' // Reference library // Function instantiation const mysql = new emysql({ password: '[database login password]', user: '[database login username]', database: 'database name' }) // Create table structure await mysql.table.create([ { 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: '创建时间' } ] } ]) // Insert data const now = new Date() await mysql.change.insert({ t: 'create_table', params: { name: 'test', create_at: now } }) // Query data const list = await mysql.query({ t: 'query_test', fields: ['name', 'id'], condition: { id: 1 } }) console.log(list) // [{id:1,name:"test"}] ```