I updated Mongo, and now the following error appears in the log: Using the aggregate command without the cursor option is deprecated
Mongo says that I have to put the second REQUIRED parameter in the aggregate function because my current usage is deprecated.
I am currently using the following PHP code (not recommended now):
$this->db->{$collection}->aggregate($options);
And return this format:
{"result":[ { "_id":"xxxxxx", "update":[ { "firstUpdateTime":xxxxxx, "updateTime":xxxxxxx, } ], "media":[ { "xxxx":{ ...
In order not to use outdated code, I add a new second parameter (but I donβt understand what to put):
$this->db->{$collection}->aggregate($options, array('cursor' => array('batchSize' => 101)));
And this returns the same information, but changes the original structure:
{"cursor":{ "id":{ "value":"xxxxxx" }, "ns":"xxxxxx.instagram", "firstBatch":[ { "_id":"xxxxxx", "update":[ { "firstUpdateTime":xxxxxx, "updateTime":xxxxxx, } ], "media":[ { "xxxxxx":{ ...
After updating Mongo forces me to change the way I read data. I donβt understand what value I should put in this second parameter called βcursorβ ...
What should I add to this second parameter? Can I set a default value without changing the structure of the results?
Document: https://docs.mongodb.com/manual/reference/method/db.collection.aggregate/ http://php.net/manual/es/mongocollection.aggregate.php
UPDATE:
If I point the cursor to a function, I no longer get the error. But, without turning to the solution, I read the log, and the warning appears randomly, I have code that I run several times, and sometimes, if it reports the warning, and others do not.
What for?