yhbatis
v0.0.12
Published
Like Mybatis for nodejs By YYH.
Downloads
8
Maintainers
Readme
Usage
//Init Part
var mysql = require('mysql');
global.yhbatis = require('yhbatis').yhbatis;
global.pool = mysql.createPool({
host :'localhost',
port : 3306,
user : 'root',
password : '1234',
connectionLimit:20,
waitForConnections:true,
typeCast : true,
multipleStatements: true
});
yhbatis.createYHBatis(
[
"C:/Users/yh/Desktop/project/homepage/mapper/query_question.xml"
]);
//XML Part
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="query_question">
<select id="getAlgorithm">
SELECT
B.*
,IF(isnull(C.result_code) ,FALSE,TRUE) AS `CHECK`
FROM
(
SELECT
*
,DATE_FORMAT(A.registed_date,'%X.%m.%d') AS registed_date_format
FROM
simuruk.algorithm_question A
) B
LEFT OUTER JOIN simuruk.algorithm_user_answer C ON
C.question_num = B.num
AND C.user_uuid = #{user_uuid}
AND C.result_code = "0"
GROUP BY B.num
</select>
</mapper>
//Use Part
var mapping = {};
mapping.user_uuid = user_uuid;
yhbatis.sqlSection("getAlgorithm",mapping,function(row){
});