How to use Binary values in MongoDB Compass?

Is there a way to use Binary values in queries in MongoDB Compass? I tried different syntaxes, but none of them work. I use the Binary type quite a lot, e.g. for user IDs and it would be really useful if I could build and analyse queries in MongoDB Compass.

One syntax that doesn’t give me an error, but produces no results is like this: { "user_id": Binary('AjHO4fVjpb6GOvVhHeHOQ==', 0) }

Hi @Nick, welcome!

You should be able to query UUID and BinData from MongoDB Compass v1.20+ (COMPASS-1083). Try using {"field": BinData(0, "valid_base64")}

For example, using the current stable version Compass v1.20.5:

You can also store/retrieve using UUIDs (subtype 4) for IDs.
Regards,
Wan.

4 Likes