[GODRIVER-771] Find with $in Created: 17/Jan/19 Updated: 27/Oct/23 Resolved: 05/Feb/19 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | CRUD |
| Affects Version/s: | 0.2.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | John Daniels | Assignee: | Isabella Siu (Inactive) |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | Bug | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Ubuntu 18.04, Mongo version 4.0, GO version 1.11 |
||
| Description |
|
When searching for objects using $in, the cursor always drops the first found object. All subsequent displays are normal.
|
| Comments |
| Comment by John Daniels [ 05/Feb/19 ] | |||||||||||||||||||||||||||||||
|
Thank! I understood my mistake! | |||||||||||||||||||||||||||||||
| Comment by Isabella Siu (Inactive) [ 05/Feb/19 ] | |||||||||||||||||||||||||||||||
|
pocoz The document is being skipped because cursor.Next() causes the cursor to go to the next document. Because of this, your first check to see if there are no documents is actually consuming the first document. Instead you can do something like this:
| |||||||||||||||||||||||||||||||
| Comment by John Daniels [ 05/Feb/19 ] | |||||||||||||||||||||||||||||||
|
Hi @isabella.siu !
I apologize for not immediately indicating this in the code.
| |||||||||||||||||||||||||||||||
| Comment by Isabella Siu (Inactive) [ 05/Feb/19 ] | |||||||||||||||||||||||||||||||
|
Hi pocoz, I tried to reproduce this with the following code, but was unable to. Does this match your usage, and if not, what's the difference?
|