[MongoDB] 데이터 파이프라인과 Lookup
집계 함수GROUP BY, SUM , AVG, COUNT$group, $sum, $avg, $count-------$lookup$matchSELECT, AS$project, $addFields, $set------[ {$match : {status : "A"}}, {$group : {"_id" : "$cust_id", total : {$sum : "$amount"}}, {$sort : {"total" : -1}]{ "cust_id" : "A", "amount" : 3}{ "cust_id" : "B", "amount" : 10}{ "cust_id" : "A", "amount" : 3}{ "_id" : "A", "total" : 6}{ "_id..
2025. 6. 16.
[MongoDB] 정렬과 페이징
db.users.find().sort({age : 1, name : -1}).skip(10).limit(10)db.users.aggregate([ {$sort : {age : -1}, {$skip : 20}, {$limit : 10}]){ "_id": ObjectId("..."), "name": "Alice", "age": 29, "email": "alice@example.com", "address": { "city": "Seoul", "zip": "04524" }, "hobbies": ["reading", "music", "swimming”],},// 추가적인 필드가 더 있다고 가저}// project 1은 포함할 필드만 선언db.users.aggregate(..
2025. 6. 16.