diff --git a/README.md b/README.md index f613223..a603c4c 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,21 @@ let up = new UpInfo().getGuest();//Simulated user upload mysql78.creatTb(up ) ``` +>>### Get a MySQL connection and do whatever you want and release the connection. +``` +let con=await mysql78.getConnection( ) ; +//do something +await mysql78.releaseConnection(con); +``` + +>>### Adding log information +``` + let up = new UpInfo().getGuest();//Simulated user upload +mysql78.isLog = true; +let back=await mysql78._addWarn("info info ", "kind", up) ; +//We can query the log by kind or apisys or apiobj or upid or upby... +``` + *** >## 框架简要说明 >![后端服务](https://github.com/www778878net/node-date78/blob/main/assets/pic/services.jpeg) diff --git a/test/test.js b/test/test.js index dd6fa9d..b1faf16 100644 --- a/test/test.js +++ b/test/test.js @@ -20,7 +20,32 @@ function loadjson(filepath) { return data; } let mysql78 = new Mysql(config["mysql"]); - + +describe('test addwarn ', () => { + it(' return 1', () => { + let up = new UpInfo().getGuest();//Simulated user upload + mysql78.isLog = true; + return mysql78._addWarn("info info ", "kind", up).then(function (result) { + + expect(result).to.equal(1); + + }) + //done(); // ֪ͨMochaԽ + }); +}); + +describe('test get and release con ', () => { + it(' return ok', () => { + return mysql78.getConnection().then(function (con) { + expect(con.config.database).to.equal("mysql"); + mysql78.releaseConnection(con).then(function (result) { + expect(result).to.equal("ok"); + }) + }) + //done(); // ֪ͨMochaԽ + }); +}); + describe('test doT ', () => { it(' return ok', () => { let up = new UpInfo().getGuest();//Simulated user upload