3 examples of 'mongodb count documents' in Python

Every line of 'mongodb count documents' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
7def count(self):
8 if self.configdict['MongoDBPath']!="":
9 client = MongoClient(self.configdict['MongoDBPath'])
10 if self.configdict['MongoDBUserName']!="" and self.configdict['MongoDBPassword']!="":
11 client.the_database.authenticate(self.configdict['MongoDBUserName'],self.configdict['MongoDBPassword'],source=self.configdict['MongoDBStorage'])
12 storedb = client[self.configdict['MongoDBStorage']]
13 collection,collection1,collection2,collection3,collection4 = storedb[self.configdict['KafkaTopicTVMetadata']], storedb[self.configdict["KafkaTopicSocialMedia"]],storedb[self.configdict['KafkaTopicNews']],storedb[self.configdict['KafkaTopicASR']],storedb[self.configdict['KafkaTopicSubtitles']]
14
15 print "Total Docs in Collection [TV Metadata], [Social Media],[News],[TV ASR],[TV SubTitles]::", collection.find().count(), collection1.find().count(), collection2.find().count(), collection3.find().count(),collection4.find().count()
509def count(self):
510 """Return the total document count.
511
512 :return: Total document count.
513 :rtype: int
514 :raise arango.exceptions.DocumentCountError: If retrieval fails.
515 """
516 request = Request(
517 method='get',
518 endpoint='/_api/collection/{}/count'.format(self.name)
519 )
520
521 def response_handler(resp):
522 if not resp.is_success:
523 raise DocumentCountError(resp, request)
524 return resp.body['count']
525
526 return self._execute(request, response_handler)
249def count(self, collection_name, query=None):
250 """Count the number of documents in a collection which match the `query`.
251
252 .. seealso:: :meth:`AbstractDB.count` for argument documentation.
253
254 """
255 dbcollection = self._db[collection_name]
256 if hasattr(dbcollection, 'count_documents'):
257 return dbcollection.count_documents(filter=query if query else {})
258
259 return dbcollection.count(filter=query)

Related snippets