需求:
- url传type,sequelize则查询
select * from xxx where type = xxx
- url不传type,sequelize则查询
select * from xxx
例:
- localhost:3000/admin/metas/list
对应sql:select * from metas
- localhost:3000/admin/metas/list?type=1
对应sql:select * from metas where type = 1
这样写不行,不传type时候查的是 select * from metas where type = null
第一次用sequelize
,请大神指点
把查询条件拿出来就行了: