Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- class
- Sequelize
- Dinosaur
- nestjs
- Bull
- 공룡게임
- MongoDB
- Express
- 게임
- 자료구조
- Nest.js
- nodejs
- GIT
- flask
- MySQL
- AWS
- OCR
- react
- JavaScript
- dfs
- TypeScript
- 정렬
- game
- Python
- jest
- mongoose
- Queue
- typeORM
- cookie
Archives
- Today
- Total
목록elemMatch (1)
포시코딩
Object Array 안에서 매칭되는 값으로 데이터 찾기 find value in array of object
{ _id: 1, members: [ { _id: 0001, id: 'Sam', rank: 0 }, { _id: 0002, id: 'Kim', rank: 1 } ], name: '테스트그룹' } 위와 같은 collection 에서 내용이 비슷한 자료가 _id 1에서부터 끝도없이 있다고 쳐보자 members 의 내용물이 다 다를때 어떻게 _id 가 1인 해당 자료를 찾을 수 있을까? $elemMatch 를 쓰면 된다. app.get('/list', (req, res)=>{ let _id = ObjectId(req.query._id); db.collection('group').find({ members: { $elemMatch: { _id: _id} } }).toArray().then((result)=>{ ..
MongoDB
2022. 7. 19. 19:16