Mongodb_driver filter by BSON.Binary from a string representation

I wan’t to do a filter for a field with a BSON.Binary representation.
I have the string like this

"a04fd31b-3ab0-36c9-b10d-abe272c88e8e"

that is represented like this in MongoDB

"userId" : LUUID("a04fd31b-3ab0-36c9-b10d-abe272c88e8e")

Inside elixir I have a field like this using the mongodb_driver

 "userId" => #BSON.Binary<a04fd31b3ab036c9b10dabe272c88e8e, uuid_old> 

I don’t know how to take the "a04fd31b-3ab0-36c9-b10d-abe272c88e8e" string and transform it to the proper Binary representation to query using the field.

Hi Edwin,

take a look at Mongo.uuid/1 (https://hexdocs.pm/mongodb_driver/Mongo.html#uuid/1). I guess that’s what you are looking for.

Hi @zookzook,

The problem here is that we are triying to find LUUID which is represented by #BSON.Binary<a04fd31b3ab036c9b10dabe272c88e8e, uuid_old> , we tried to use the function that you mentioned but it just returned an empty result.because it returns us a #BSON.UUID<848e90e9-5750-4e0a-ab73-66ac6b328242> structure.

Any other idea?

Oh, I see, it is the type uuid_old. This is the legacy UUID. I need to add support for this type.