在mongo中选择列表的前N个或者后N个

在mongo中选择列表的前N个或者后N个

标签(空格分隔): mongo


  • db.getCollection(‘entity_info’).find( { }, {“attr_attr_value”: {“$slice”: 3 } })

db.collection.find( { field: value }, { array: {$slice: count } } );

This operation selects the document collection identified by a field named field that holds value and returns the number of elements specified by the value of count from the array stored in the array field. If count has a value greater than the number of elements in array the query returns all elements of the array.

猜你喜欢

转载自blog.csdn.net/jiangzhenkang/article/details/82111134