nodejs---sequelizeはOpを使わないで、警察に通報しません.
1785 ワード
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/