2 / 2
Mar 24

When I use this filter
filter := bson.D{{scheduleOrderGUID, scheduleOrderGUID}}
I am NOT able to get the document;

however if I use
filter := bson.M{“scheduleOrderGUID”: scheduleOrderGUID}
Then it is able to find this document.

Interestingly the query with ‘D’ was working successfully for over a month. Suddenly today it does not work.

Can you please help me in finding / fixing the issue?
Please let me know if I need to provide more details.
Thanks

@MAHESH_VELANKAR thanks for the question! I’m not sure if this is a typo, but your bson.D filter uses the same variable for the key and value:

bson.D{{scheduleOrderGUID, scheduleOrderGUID}}

Assuming the value of scheduleOrderGUID is “abcd1234”, that would effectively create the filter

{"abcd1234": "abcd1234"}

instead of the intended filter

{"scheduleOrderGUID": "abcd1234"}

I’m not sure how the former would have ever worked, so it’s odd that it was working and then stopped working. Can you confirm if the bson.D filter is a typo?