728x90
1. app.js
//연산자 사용하기 위해서 가져온다
const { Op } = require("sequelize");
2. 조회
(1) Op.gt : greater than (초과)
(2) Op.gte : greater than or equal to (이상)
(3) Op.lt : less than (미만)
(4) Op.lte : less than or equal to (이하)
(5) Op.ne : not equal (같지 않음)
(6) Op.or : or (또는)
(7) Op.in : in (배열 요소중 하나)
(8) Op.notIn : not in (배열 요소와 모두 다름)
쿼리(조회) — Sequelize Of Node.js translate V5 5 documentation
JSON 데이터 타입은 PostgreSQL, SQLite, MySQL 그리고 MariaDB에서 제공합니다. PostgreSQL PostgreSQL의 JSON 데이터 형식은 이진 표현이 아닌 일반 텍스트로 값을 저장합니다. 단순히 JSON 표현을 저장하고 검색
pjt3591oo.github.io
3. 예시
async function select() {
const user = await User.findAll({
where: {
age: { [Op.gte]: 23 },
[Op.or]: [{ age: { [Op.gt]: 23 } }, { name: "안녕" }],
},
order: [["age", "ASC"]],
// limit: 1,
// offset: 1,
});
const temp = user.map((i) => i.dataValues);
console.log(temp);
}
728x90
'개발 > node.js' 카테고리의 다른 글
sequelize 외래키 설정 (0) | 2022.08.25 |
---|---|
[Node.js] mysql FOREIGN KEY (0) | 2022.08.18 |
[Node.js] 로그인 만들기 (0) | 2022.08.18 |
[Node.js] crypto, bcrypto (0) | 2022.08.17 |
[Node.js] access token, refresh token 을 활용하여 로그인 유지시키기 (0) | 2022.08.16 |