JSPM

@nestjs-kitchen/mybatis-mapper

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q53827F
  • License MIT

A mybatis mapper in NextJS.

Package Exports

  • @nestjs-kitchen/mybatis-mapper

Readme

@nestjs-kitchen/mybatis-mapper

NPM Version NPM License codecov

A mybatis mapper in NextJS.


Install

$ npm install --save @nestjs-kitchen/mybatis-mapper

Usage

  1. 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 {}
  2. 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