use UUID in mongoDB query (filter by id)

0

Hello everyone,

I try to make a findQuery for mongoDB in jaspersoft studio but when I try to use a UUID in the process, I always have 0 results.

Example query :

{
  'collectionName' : 'Orders',
  'findQuery' : {
    "_id" :  UUID("4925b1a6-5cd6-6d19-9f2a-7a0083a7bb9a")
  }
}

Is there something wrong in my query in your opinion ?

Thanks for your help

arnaudsimon091's picture
Joined: Nov 26 2018 - 12:25pm
Last seen: 1 month 1 week ago

1 Answer:

0

I finally found how to use a UUID in a mongo query.

You should first convert your UUID in base64, to do so I used 2 online converters, the first one gave me the 12 first base64 caracters, the second one the 12 last 

(yes, this is strange).

To give you a concrete example : 

Basic UUID : 41e73145-2489-54e1-d2fc-d400bea5e9b1

Site 1 : QecxRSSJVOHS/AAA1AC+pQ

Site 2 : RTHnQYkk4VTS/NQAvqXpsQ==

Final base64 result :  QecxRSSJVOHS/NQAvqXpsQ==

Then to use it in Jasper, you'll need this syntax : 

_id: new BinData(4,"QecxRSSJVOHS/NQAvqXpsQ==")

 

arnaudsimon091's picture
Joined: Nov 26 2018 - 12:25pm
Last seen: 1 month 1 week ago
Feedback