Package Exports
- @nestjs-kitchen/mybatis-mapper
Readme
@nestjs-kitchen/mybatis-mapper
A mybatis mapper in NextJS.
Install
$ npm install --save @nestjs-kitchen/mybatis-mapper
Usage
Auto load/watch mappers from specified folder:
// app.module.ts import { MybatisMapperModule } from "mybatis"; import { AppService } from "./app.service"; @Module({ // load and watch mappers from specified folder. imports: [MybatisMapperModule.register({ patterns: "./mapper", watchPatterns: "./mapper" })], controllers: [], providers: [AppService], }) export class AppModule {}
get sql from mappers:
// app.service.ts import { Injectable } from '@nestjs/common'; import { MybatisMapper } from 'mybatis'; @Injectable() export class AppService { constructor(private mapper: MybatisMapper){} getSql(): string { const param = { category : 'apple', price : 100 } return this.mapper.getStatement('fruit', 'testIf', param, { language: 'sql', indent: ' ' } } }
License
MIT License