-
-
Save jaimemin/bd1ef40de9efdf5c7319bd2d8f891be4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 도큐먼트에 재고 수량 키 "in_stock"과 판매 수량 키 "num_sold"가 있다고 가정 | |
// 두 키는 상수이므로 참고할 수 없기 때문에 다음 쿼리는 동작 안 함 | |
db.stock.find({"in_stock": "this.num.sold"}); // 동작 X | |
// 누군가가 상품을 구매할 때마다 "in_stock" 값을 감소시킨다고 가정 | |
// 품절 상품 확인하는 쿼리는 다음과 같음 | |
db.stock.find({"in_stock": 0}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment