开发者

MongoDB Database, order by a field which is a string field but with a number in it

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜