Jump to content
We've recently updated our Privacy Statement, available here ×

use UUID in mongoDB query (filter by id)


arnaudsimon091
Go to solution Solved by arnaudsimon091,

Recommended Posts

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

Link to comment
Share on other sites

  • 3 weeks later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution

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==")

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...