发布于 2015-09-14 14:54:20 | 105 次阅读 | 评论: 0 | 来源: 网络整理
The $pop operator removes the first or last element of an array. Pass $pop a value of 1` to remove the last element in an array and a value of -1 to remove the first element of an array. Consider the following syntax:
db.collection.update( {field: value }, { $pop: { field: 1 } } );
This operation removes the last item of the array in field in the document that matches the query statement { field: value }. The following example removes the first item of the same array:
db.collection.update( {field: value }, { $pop: { field: -1 } } );
Be aware of the following $pop behaviors:
1.1 新版功能.