Sequelize模糊查询

 

const Sequelize = require('sequelize');
const Op = Sequelize.Op;

User.findAll({
 raw: true,
  order: [
      ['name', 'DESC']
  ],  // 排序
  where: {
    // name: 'cheny', // 精确查询
    mobile_no: {
      // 模糊查询
      [Op.like]:'%' +mobile_no + '%'
    }
  },
  attributes:['id','name'], // 控制查询字段
})

 

中文参考:

https://github.com/demopark/sequelize-docs-Zh-CN

https://segmentfault.com/a/1190000011583806

 

egg、sequelize联表查询

https://blog.csdn.net/qq_30101131/article/details/79474905 

 

 

.

你可能感兴趣的:(Sequelize模糊查询)