nodejs --- sequelize不用Op,不报警

const Sequelize = require('sequelize');
const Op = Sequelize.Op;
const operatorsAliases = {
  $eq: Op.eq,
  $ne: Op.ne,
  $gte: Op.gte,
  $gt: Op.gt,
  $lte: Op.lte,
  $lt: Op.lt,
  $not: Op.not,
  $in: Op.in,
  $notIn: Op.notIn,
  $is: Op.is,
  $like: Op.like,
  $notLike: Op.notLike,
  $iLike: Op.iLike,
  $notILike: Op.notILike,
  $regexp: Op.regexp,
  $notRegexp: Op.notRegexp,
  $iRegexp: Op.iRegexp,
  $notIRegexp: Op.notIRegexp,
  $between: Op.between,
  $notBetween: Op.notBetween,
  $overlap: Op.overlap,
  $contains: Op.contains,
  $contained: Op.contained,
  $adjacent: Op.adjacent,
  $strictLeft: Op.strictLeft,
  $strictRight: Op.strictRight,
  $noExtendRight: Op.noExtendRight,
  $noExtendLeft: Op.noExtendLeft,
  $and: Op.and,
  $or: Op.or,
  $any: Op.any,
  $all: Op.all,
  $values: Op.values,
  $col: Op.col
};
const sequelize = new Sequelize('cd', 'root', '', {
  host: 'localhost',
  dialect: 'mysql',

  pool: {
    max: 5,
    min: 0,
    acquire: 30000,
    idle: 10000
  },

 

  // 请参考 Querying - 查询 操作符 章节
  operatorsAliases: operatorsAliases   //如果将这个设置为true(默认就是,可以注释掉)就可以使用别名但是会报警所以这样写,false就不能使用
});

const User = sequelize.define('user', {
  username: Sequelize.STRING,
  birthday: Sequelize.DATE,
  core : Sequelize.INTEGER,
});


User.findAll({
	attributes:  ["core"] ,
	where:{
		$or: [{"core": 90}, {"core": 100}]
	}
}).then(result=>{ 
	console.log(result)
	//console.log(typeof result)
}) 

//sequelize.sync()
//  .then(() => user.create({
//    username: 'jin',
//    birthday: new date(1987, 6, 20),
//	core : 70
//  }))
//  .then(jane => {
//    console.log(jane.tojson());
//  });
sequelize官方文档:  http://docs.sequelizejs.com/

猜你喜欢

转载自blog.csdn.net/dongmelon/article/details/79409817