MongoDB Realm Studio - filter by object id?

Hi all,

a question that is so obvious - but I cant find an answer anywhere and I cant figure it out myself.

  • open your local database with MongoDB realm studio
  • open any collection …

I am ok filtering for text fields. However my primary key field (_id) is of type ObjectId - and I just cant figure out how to filter on that field?

If I try

_id=“61783f515bc41c92e4b6e298”

I get told "Unsupported comparison between type ‘objecId’ and ‘string’

However something like this … _id = ObjectId(“61783f515bc41c92e4b6e298”) also doesnt work … How do I do it?? …

Any help welcome - I just couldn’t find an example anywhere.

Cheers,
Steve

1 Like

This is a really good question. I hope one of the MongoDB folks can address it.

1 Like

Hi Steve/Jay,

The query is trying to interpret the value as a string and has been reported here.

Please try the following:

_id = oid(61783f515bc41c92e4b6e298)

Regards
Manny

2 Likes

Thank you very Much Manny! Mystery resolved - that works!

2 Likes

Wow - never thought to look in the Realm-JS git. Thank you for addressing it!

It may be a cool note to add to the RealmStudio docs.

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.