码迷,mamicode.com
首页 > 其他好文 > 详细

Sequelize模糊查询

时间:2019-11-02 19:41:00      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:查询   raw   name   use   findall   精确   mob   require   esc   

 

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‘], // 控制查询字段
})

 

 

 

.

Sequelize模糊查询

标签:查询   raw   name   use   findall   精确   mob   require   esc   

原文地址:https://www.cnblogs.com/xiangsj/p/11783666.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!