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 

 

 

.

posted @ 2019-11-02 19:16  James2019  阅读(3325)  评论(0编辑  收藏  举报