I have updated mongo and now in the log the following error appears: Use of the aggregate command without the cursor option is deprecated
Mongo says that I should put a second REQUIRED parameter to aggregate function, because my current usage is deprecated.
I currently use the following code PHP (now is deprecated):
$this->db->{$collection}->aggregate($options);
And return this format:
{"result":[
{
"_id":"xxxxxx",
"update":[
{
"firstUpdateTime":xxxxxx,
"updateTime":xxxxxxx,
}
],
"media":[
{
"xxxx":{ ...
To not use an deprecated code I add the new second parameter (but I do not understand what to put):
$this->db->{$collection}->aggregate($options, array('cursor' => array('batchSize' => 101)));
And this returns the same information but varies the initial structure:
{"cursor":{
"id":{
"value":"xxxxxx"
},
"ns":"xxxxxx.instagram",
"firstBatch":[
{
"_id":"xxxxxx",
"update":[
{
"firstUpdateTime":xxxxxx,
"updateTime":xxxxxx,
}
],
"media":[
{
"xxxxxx":{ ...
After the update Mongo forces me to change the way I read the data. I don't understand what value I should put in that second parameter called "cursor"...
What should I put in that second parameter? Can I set a default value without altering the structure of results?
Doc: https://docs.mongodb.com/manual/reference/method/db.collection.aggregate/ http://php.net/manual/es/mongocollection.aggregate.php
UPDATE:
If I indicate the cursor in the function I no longer receive the error. But without applying to the solution, I read the LOG and the warning appears at random, I have a code that I run several times and sometimes if it reports the mentioned warning and others do not.
Why?