"php mongodb - use of the aggregate command without the cursor option is deprecated. what?" Code Answer

4

when you query something to mongodb and you expect results, you will have this variable called cursor, which simply is a pointer to the document you currently did read. it is just like a scrollbar in the browser.

you can specify how many documents it should read into a buffer batchsize as you did with value 1.

it is useful when you know how much documents you expect to read. when you only need 10 documents, you can get all those in a single network packet using batchsize => 10. when specify batchsize => 5, it will take longer because it does take two network packets to the database to get the expected 10 documents.

you are safe using the default batchsize.

you can try to iterate over the cursor using foreach like in an example in the docs: http://php.net/manual/en/class.mongocommandcursor.php

im not sure if the php.net documentation is up to date with the most current version of the mongodb driver.

By chakrit on February 22 2022

Answers related to “php mongodb - use of the aggregate command without the cursor option is deprecated. what?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.