MongoDB Java Driver Filter Integer Value of a String

Viewed 20

I have MongoDB Document parameter of type "real" number but is represented in the DB as a string- e.g "cId"="200" instead of "cId"=200I have to query the DB for a range of numbers; e.g. filter equivalent to SELECT ALL where cId is less than 10 and greater than 5.

Is there a way to query the integer value of this parameter using a similar functional equivalent to Integer.parseInt(str); for example

My filter looks like

Bson filter = Filters.and(Filters.gt("cId", "0"), Filters.lt("cId","4"));

I'm hoping for an equivalent of something like

Bson filter = Filters.and(Filters.gt("cId", valueOf("0")), Filters.lt("cId",valueOf("4")));

Thanks...

0 Answers
Related