在 php 中使用 withlimit
和in获取 mongo 文档的内部数组。skip
$db->users->findOne(array('_id' => new MongoId('5045fa0213cfcdfc06000008')));
上面的查询会给我下面的 mongo 数组
[_id] => MongoId Object (
[$id] => 5045fa0213cfcdfc06000008
)
[items] => Array (
[0] => 13
[1] => 4
[2] => 3
[3] => 7
[4] => 10
[5] => 11
[6] => 28
[7] => 54
[8] => 31
[9] => 33
[10] => 37
[11] => 12
)
是否可以与上面的mongo doc一起使用limit
,skip
如下所示
$db->users->
findOne(array('_id' => new MongoId('5045fa0213cfcdfc06000008')))->
limit(5)->skip(5);
这将输出为
[_id] => MongoId Object (
[$id] => 5045fa0213cfcdfc06000008
)
[items] => Array (
[5] => 11
[6] => 28
[7] => 54
[8] => 31
[9] => 33
)
以及如何items
使用 mongo 计算数组的总数?