Notice
Recent Posts
Recent Comments
Link
HANA -J
TIL - Sequelize 본문
1. SELECT * FROM node.users;
User.findAll({});
2. SELECT name, age FROM node.users;
User.findAll({
attribute:['name', 'age'],
});
3. SELECT name, age From node.users WHERE role =1 AND age>30;
const {OP} = require('sequelize');
const {User} = require('../models');
User.findAll({
attribute :['name', 'age'],
where :{
role:1,
age:{[Op,gt]:30},
},
});
4. SELECT id, name FROM users WHERE role =0 OR age>30;
const {OP} = require('sequelize');
const {User} = require('../models');
User.findAll({
attribute :['name', 'age'],
where :{
[Op.or]: [{role:0}, {age :{[Op.gt]:30}}],
},
});
728x90
'what I Learnd > TIL' 카테고리의 다른 글
Sequelize findAll , dataValues만 가져오기 (0) | 2021.12.23 |
---|---|
HTTP (0) | 2021.12.17 |
TIL - invalid ELF header (0) | 2021.12.10 |
TIL -CORS (0) | 2021.12.09 |
TIL - HTTP API 설계 (0) | 2021.12.04 |
Comments