Apply limit in mapreduce function in php?

Posted by Rohan Kumar on Stack Overflow See other posts from Stack Overflow or by Rohan Kumar
Published on 2012-06-29T09:11:17Z Indexed on 2012/06/29 9:15 UTC
Read the original article Hit count: 317

Filed under:
|

How to apply limit in php, mongodb when using mapreduce function? I tried this

$cmd=array(// codition array
"mapreduce" => "user", 
"map" => $map,
"reduce" => $reduce,
"out" => array("inline" => 1),
"limit"=>2
);

$db=connect();
$query = $db->command($cmd);// run command

But its not working it gives 2 documents.I can't use limit on sub documents. If I have 100's of sub documents and then I want paging in sub documents.Then it fails.Is it possible to apply limit on sub documents?

© Stack Overflow or respective owner

Related posts about php

Related posts about mongodb