Page 313 - Nodejs 교과서 개정2판
P. 313
User.findAll({
attributes: ['name', 'age'],
where: {
married: true,
age: { [Op.gt]: 30 },
},
});
.Z42-ীࢲח undefinedۄח ܐഋਸ ਗೞ ঋਵ۽ where ২࣌ীח undefinedо ٜযоݶ উ ؾפ
࠼ чਸ ֍Ҋ ೞݶ nullਸ न ࢎਊೞࣁਃ
age ࠗ࠙ ઑӘ ౠೠؘਃ द௬ۄૉח ߄झ݀ ёܳ ࢎਊ೧ࢲ ௪ܻܳ ࢤࢿ೧ঠ ೞ۽ Op.gt э
ౠࣻೠ োٜ ࢎਊؾפ Sequelize ё ղࠗ Op ёܳ ࠛ۞৬ ࢎਊפ { [Op.gt]: 30 } &4
ޙߨפ ਸ ଵҊೞӡ ߄ۉפ
ॳח ো۽ח Op.gt ୡҗ Op.gte ࢚ Op.lt ݅ Op.lte ೞ Op.ne э ঋ Op.or ژח
Op.in ߓৌ ਃࣗ ೞա Op.notIn ߓৌ ਃࣗ৬ ݽف ܴ ١ णפ
Op.orܳ ೠߣ ࢎਊ೧ࠇद
SELECT id, name FROM users WHERE married = 0 OR age > 30;
const { Op } = require('sequelize');
const { User } = require('../models');
User.findAll({
attributes: ['id', 'name'],
where: {
[Op.or]: [{ married: false }, { age: { [Op.gt]: 30 } }],
},
});
Op.or ࣘࢿী OR োਸ ਊೡ ௪ܻٜਸ ߓৌ۽ աৌೞݶ ؾפ
SELECT id, name FROM users ORDER BY age DESC;
User.findAll({
attributes: ['id', 'name'],
order: [['age', 'DESC']],
});
द௬ۄૉ ۳ ߑधݴ order ২࣌ਵ۽ оמפ ߓৌ উী ߓৌ ח ী ೞࣁਃ ۳ ԙ