Node Version:
Egg Version:
Plugin Name: egg-mysql
Plugin Version: ^1.0.0
Platform:
egg-mysql将where条件语句查询封装在对象里,
const type = this.query.type;
const page = this.query.page || 1;
const pageSize = this.query.pageSize || 10;
const pangufe = this.app.mysql.get('pangufe');
const results = yield pangufe.select('log', {
where: {type: type},
columns: ['type', 'ua', 'page', 'error_message', 'create_time'],
orders: [['create_time', 'desc'], ['id', 'desc']],
limit: pageSize,
offset: pageSize * (page - 1)
});
这样还能不能实现 某条件可有可无 的查询?
功能诸如PHP的Yii框架中,若有此条件,则加一个andWhere就好。
$find = LiveContent::find()->with('user');
if (!$this->getLive