var userid = req.session.userid ; var sql = "select count(*) count from `html` where userid= ?" // var sql = "select `dom` from `html` where userid=? "; var dataList = await query(sql,[userid]);
if(dataList[0].count == 0 ){ res.json({})
}elseif(dataList[0].count > 5) { // if len > 5 , merge all and update mysql console.log("Merge the recorder in the database.");
var sql = "select `id`,`dom` from `html` where userid=? "; var raws = await query(sql,[userid]); var doms = {} var ret = newArray();
var sql = "delete from `html` where id = ?"; var result = await query(sql,raws[i].id); } var sql = "insert into `html` (`userid`,`dom`) values (?,?) "; var result = await query(sql,[userid, JSON.stringify(doms) ]);
res.render = functionrender(view, options, callback) { var app = this.req.app; var done = callback; var opts = options || {}; var req = this.req; var self = this;
. . . . . .
// render app.render(view, opts, done); };
调用了 app.render,继续跟
/node_modules/express/lib/application.js
1 2 3 4 5 6 7 8 9 10 11 12 13
app.render = functionrender(name, options, callback) { var cache = this.cache; var done = callback; var engines = this.engines; var opts = options; var renderOptions = {}; var view;
exports.renderFile = function () { var args = Array.prototype.slice.call(arguments); var filename = args.shift(); var cb; var opts = {filename: filename}; var data; var viewOpts; . . . . . . return tryHandleCache(opts, data, cb); };