edwinallenz

edwinallenz

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.

First Post!

zookzook

zookzook

Hi Edwin,

take a look at Mongo.uuid/1 (Mongo — mongodb-driver v1.6.3). I guess that’s what you are looking for.

Last Post!

zookzook

zookzook

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

Where Next?

Popular in Questions Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement