Lin Du
Lin Du

Reputation: 102297

mongodb, what's the `cursor.exec` mean?

I search for hours, but still not found any information about it.

var cursor = db.collection('students');
cursor.skip(10).limit(10)

cursor.exec(function(err, result) {...})

Is there any docs about exec?

Upvotes: 0

Views: 1714

Answers (2)

Parshuram Kalvikatte
Parshuram Kalvikatte

Reputation: 1646

When you make a query to a MongoDB, you are returned a cursor to an array stored in the server’s memory.

You can think the cursor as a pointer or the reference to array Data So when you call cursor.next();

Next Array array data is outputted Whenever you use an aggregation framework each pipeline stage can output max(16 MB) as it is can use only 16MB of RAM space

var cursor = db.collection('students');

So your answer here cursor is nothing but a pointer to the array or data retrieved and exec nothing but helper method of Mongoose check @str link

Upvotes: 1

Related Questions