MongoDB count () returns 0 incorrectly if requested

Our database is currently working, and everything seems beautiful. I wanted to make some statistics, so I made some standard calls. Basically, I need the amount of certain data.

First, a few basic calls to show you that there is actually data in the database.

> db.files.count() 814639 > db.files.find({"migrated":true}) { "migrated" : true, "filename" : "bleh",... } ... 

So clearly there is data, and the call returns it. Now I want to find out how many results are there, but I get the following:

 > db.files.count({"migrated":true}) 0 

And I did it too:

 > db.files.find({"migrated":true}).count() 0 

Does anyone have any ideas why this might happen?

Versions:

 > db.version() 1.8.1 

Any help would be greatly appreciated

+4
source share
2 answers

For a while, but I'm closing it now. But it was a corrupt database. Had to manually move all the items from one database to a new one, because the backup stopped when it detected corrupted data, and the actual data was not subsequently copied.

+1
source

This question is probably related to the following errors:

In my case (mongodb 2.0.1) was due to database corruption. See find (). Count () error?

+1
source

All Articles