基于sequelize-typescript库提供
npm install sequelize-typescript
查询
logging:console.log能打印出sql
attributes: [‘id’, ‘name’], 指定查询的字段
required: false 这是左查询 left join
// in 查询
const systemHospital = await CheckHospitalModel.findAll({
where: {
// 正常查询
code: code,
// in查询
hospital: {
[Op.in]: hospitalIdList
},
// 模糊查询
region: {
[Op.like]: `${
code}%`
},
date: {
[Op.gte]: dayjs(year)
.startOf('y')
.toDate(),
[Op.lt]: dayjs(year)
.startOf