Skip to content
Advertisement

Get amount of objects saved in MongoDB using Pymongo

I’m trying to get amount of objects saved in MongoDB with

JavaScript

but I’m getting an error

JavaScript

I’m using Pymongo 2.0

Advertisement

Answer

The find() function for pymongo returns a cursor object (not an array). Pymongo does include a count_documents function. Meaning the code should look like this:

JavaScript

Edit: Updated to correct solution.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement