I have a MongoDB and I nee开发者_C百科d to order by a field (id), but this field is a string field with a number in it.
Example:
{
"_id": ObjectId("4e60f8c2b1638e5479c8ba6f"),
"id": "3188",
"type": "P"
}
The id field with value "3188" I need to order on that field as if it's an integer. Has MongoDB got some magic that it can do this?
Thanks!
Magick of mongodb not enough to sort string as integer ;)
So there is only one solution is to make int field from string field and sort on it.
精彩评论