String filter works correctly but when I try to apply { branch: “634aeffdbccd9d0f6297bb62” } it does not work and returns null.
How to apply filter for ObjectId type?
String filter works correctly but when I try to apply { branch: “634aeffdbccd9d0f6297bb62” } it does not work and returns null.
How to apply filter for ObjectId type?
Hello @Donis_Rikardo, Welcome to the MongoDB community forum,
It would be helpful if you provide more details,
I am not too sure, but I think you need to use EJSON syntax to make sure the string "634aeffdbccd9d0f6297bb62" is processed as an ObjectId. So I would try:
{ "branch" : { "$oid" : "634aeffdbccd9d0f6297bb62" } }
Thanks. There is zero info about that in the documentation.
I got the $oid part from the examples.
Thanks. I’m blind. Or it was another docs
Your not. Little details like that are easily skipped.
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.