草庐IT

ownedparts

全部标签

mongodb - 从子文档的数组中查找数据时使用 $slice

我需要从“_id”定义的文档的子文档数组中获取最新条目。文档看起来像这样:{"_id":"nex67","ownedparts":[{"id":"tool1","history":[{"time":ISODate("2016-06-07T09:12:54.015Z"),"value":300},{"time":ISODate("2016-06-07T09:12:54.015Z"),"value":240}]},{"id":"screw1","history":[{"time":ISODate("2016-06-07T09:12:54.015Z"),"value":500}]}]}通过这