开发者

Items in document rearrange upon save

I am using Codeigniter and MongoDB and I am just wondering about the order of items in a document.

When I first save (create) a new document I set the order of the items in one way, but when I do an update to the document the items get rearranged. Is this normal?

First save:

{
    "_id开发者_如何学运维": ObjectId("4e96bd063dc7937202000000"),
    "firstname": "James",
    "lastname": "Bond",
    "fullname": "James Bond",
    "followers": "",
    "following": "",
    "lastlogin_at": "2011-10-13 12:33:47"

}

Second save:

{
    "_id": ObjectId("4e96bd063dc7937202000000"),
    "firstname": "James",
    "followers": "",
    "following": "",
    "fullname": "James Bond",
    "lastlogin_at": "2011-10-13 12:33:47",
    "lastname": "Bond"
}


I wouldn't be overly concerned with the order of items within the object. When you reference them you use the property name; they're not like columns in a SQL database where you would reference them by a column index. The order of properties in the DB shouldn't affect your code in any way ;)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜