[GODRIVER-1452] Issue in filtering based on subdocument Created: 26/Dec/19 Updated: 08/Jan/20 Resolved: 08/Jan/20 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | CRUD |
| Affects Version/s: | 1.1.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Abhay Kumar | Assignee: | Isabella Siu (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows |
||
| Description |
|
For the document below { "_id":ObjectId("5e00841f03d2a48f209b0905"), "uID":\{"ABC"}, "units":[{"locID":"11","size":"small","accessible":true,"enabled":true,"reserved":false,"occupied":false}, when I try to filter based on uID and units.locID I'm getting any documents Here is the filter and option , {"units", 1}}) I've tried this which gives back all units filter: = bson.D{ {"uID", "ABC"}, {"units.locID", "11"}} I want to get the unit which has uID = ABC and locID = 11
|
| Comments |
| Comment by Isabella Siu (Inactive) [ 08/Jan/20 ] | |||||||
|
For what you are doing, you should use an aggregation pipeline:
Please note that the GODRIVER project is for reporting bug or feature suggestions for the driver. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag. A question like this involving more discussion would be best posted on the mongodb-users group. |