Du kan kombinere find og count.
db.collection.find({ query }).count()I nyere versioner er countDocuments() at foretrække, fordi count() kan være unøjagtig på sharded collections.
Du kan kombinere find og count.
db.collection.find({ query }).count()I nyere versioner er countDocuments() at foretrække, fordi count() kan være unøjagtig på sharded collections.