Is there a way to output aggregation result to a collection when using Mongo PHP driver? Usually it's done with $out : "collection_name"
when running aggregate in mongo shell like this:
db.collection.aggregate([
{$match},
{$group},
{
$out : "newcollection"
}
]);
When using PHP driver, like this:
$m = new MongoClient("localhost");
$c = $m->selectDB($this->mongodb)->selectCollection($this->scrapedCollection);
$r = $c->aggregate($pipeline);
it returns result to $r
and then you have to iterate over results and insert them one by one in new collection.
I'd like to pass $out
option to Mongo PHP Driver in aggregate function.
I couldn't find answer in their docs, anyone faced this situation?
$ out也是一个聚合管道运算符(就像$ match和$ sort一样),因此请在管道的最后阶段使用它,指定输出集合名称。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.