@dlovely/mysql
Version:
对mysql的简易连接,能创建数据库、数据表管理,并使用sql编辑器
53 lines (42 loc) • 966 B
Markdown
- [快速入门](
- 客户端
- 数据库
- 数据表
- 数据表操作
- 增
- 删
- 改
- 查
- 联表
```sh
$ npm install --save @dlovely/mysql
$ yarn add @dlovely/mysql
$ pnpm add @dlovely/mysql
```
```ts
// mysql-table.ts
export const table1_columns = [
{ name: 'id', readonly: true, not_null: true, has_defa: true },
{ name: 'name', readonly: false, not_null: true, has_defa: false }
]
// mysql.ts
import { createMySqlPool } from '@dlovely/mysql'
import { table1_columns } from './mysql-table'
const server = createMySqlPool()
export const database = server.createDataBase('database')
export const table1 = database.createTable('table1', table1_columns)
// index.ts
import { table1 } from './mysql'
!async function() {
const result = await table1.select()
console.log(result)
}
```