MongoDB的2.4介紹帶蓋陣列:
http://docs.mongodb.org/manual/release-notes/2.4/#limit-number-of-elements-in-an-array封頂陣列MongoDB中2.4
考慮以下文檔結構(帶有嵌套陣列):
thread { "_id" : ObjectId("5191039d48ef54c24a000002"), "messages" : [ {"content" : "hello", "sent_at": "ISODate("2013-05-13T15:15:44.162Z")}, {"content" : "hi again", "sent_at": "ISODate("2013-05-13T15:15:48.162Z")} ] }
使用新的封端的陣列特徵,如何能當我添加一個新的消息(例如第51個消息)時,我會刪除最舊的消息嗎?
換句話說,我怎樣才能限制嵌套數組「消息」50項?
的文檔顯示如何做到這一點的例子:http://docs.mongodb.org/manual/tutorial/limit-number-of-elements-in-updated-array /#pattern – 2013-05-13 17:15:17