1.0.8 • Published 3 years ago

xiao-koa-mysql v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

xiao-koa-mysql

XiaoKoa快速开发系列之操作MySQL插件

安装

npm i xiao-koa-mysql

使用

index.ts

import { Application, xiaoKoaApp } from "xiao-koa";
import xiaoKoaMysql from "xiao-koa-mysql";

@Application
export default class TestApplication {
  main(app: xiaoKoaApp) {
    app.mount(xiaoKoaMysql);

    app.run(__dirname, 1234);
  }
}

application.yml

...

mysql:
  connectionLimit: 10
  host: localhost
  user: root
  password: 123456
  database: test

mapping.ts

import { Mapping, Sql } from "xiao-koa-mysql";

@Mapping()
export class TestMapping {
  @Sql(`select * from user where id = #{id}`)
  findAll(id: number): any {}
}

装饰器

@Mapping

@Mapping(?alias)

被Mapping标识的类将会自动添加实例进入Service容器里

@Sql

@Sql("Sql语句")

被Sql标识的函数接收的参数将填入Sql语句占位符内#{},并将查询出来的数据当做函数被调用时的返回值

疑问交流

QQ群: xiao-koa(917968816)

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago