thinkjs中自定義sql語句

一直覺得在使用thinkjs時,只能是它自帶的sql語句查詢,當遇到相似於這樣的sql語句時,殊不知道這該怎樣來寫程序,卻不知原來thinkjs能夠執行自定義sql語句sql

SELECT * from adinfo WHERE 1481286720 BETWEEN stime AND etime OR (1481297520 BETWEEN stime AND etime)
model.query(...args) 
return {Promise} //指定 SQL 語句執行查詢。

至關於:post

let addCheck = await this.model('adinfo').query('SELECT * from adinfo WHERE ' + stime + ' BETWEEN stime AND etime OR (' + etime + ' BETWEEN stime AND etime)');

完整版就是這樣的:this

let postDatas = this.post();
let stime = postDatas.stime;
let etime = postDatas.etime;
// SELECT * from adinfo WHERE 1481286720 BETWEEN stime AND etime OR (1481297520 BETWEEN stime AND etime)
// let addCheck = await this.model('adinfo').where({stime:['between', 'stime,etime'],etime:['between', 'stime,etime'],_logic:"OR"}).select();
let addCheck = await this.model('adinfo').query('SELECT * from adinfo WHERE ' + stime + ' BETWEEN stime AND etime OR (' + etime + ' BETWEEN stime AND etime)');

原來,thinkjs仍是那麼的神祕~spa

相關文章
相關標籤/搜索