express-mybatis-mapper

1.0.1 • Public • Published

express-mybatis-mapper

GitHub license

mybatis-mapper express middleware

It can be installed as follows:

npm install --save express-mybatis-mapper

Middleware registration is as follows.
Pass the path of mybatis files to be registered as an array.

const express = require("express");
const app = express();
......
const mybatis = require("express-mybatis-mapper");
app.use(mybatis(["./example.xml", "./example2.xml"]));
......

After that, you will have a mybatisMapper field in your request object.
If you pass mybatis namespace, id, and context object in order to the getStatement method, the query text is generated and returned.

...
router.get("/", (req, res, next)=>{
    ...
    //generate query text
    const query = req.mybatisMapper.getStatement("example", "SELECT.001", {foo:"bar"});
    ...
});
...

Package Sidebar

Install

npm i express-mybatis-mapper

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

3.64 kB

Total Files

5

Last publish

Collaborators

  • myyrakle