string / integer comparison

3,527 views
Skip to first unread message

Khaled

unread,
Dec 20, 2010, 8:31:35 PM12/20/10
to mongodb-user, khaled...@gmail.com
I have a string field that stores numbers which i want to search
against using lte / gte, how can i tell mongodb to treat the field as
number ?

as {"value" => {"$lte" => "40000"}} doesn't work !

thanks

Nat

unread,
Dec 20, 2010, 8:50:39 PM12/20/10
to mongodb-user
Hi,

It has been answered here... http://stackoverflow.com/questions/3521601/is-it-possible-to-cast-in-a-mongodb-query
that you would need to use $where

Scott Hernandez

unread,
Dec 20, 2010, 8:55:02 PM12/20/10
to mongod...@googlegroups.com
You should store your numbers as numbers, not strings.

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

jhmu...@gmail.com

unread,
Jun 29, 2017, 5:42:32 PM6/29/17
to mongodb-user, khaled...@gmail.com
Reply all
Reply to author
Forward
0 new messages