Fix AttributeError caused by updated pymongo version
AttributeError: 'Cursor' object has no attribute 'count' is fixed.
Change-Id: Id1b9133376d5a7dcb3998c623163bb57dd5c534b
Signed-off-by: Gulsum Atici <gulsum.atici@canonical.com>
diff --git a/osm_common/dbmongo.py b/osm_common/dbmongo.py
index f5c4d30..c9b384b 100644
--- a/osm_common/dbmongo.py
+++ b/osm_common/dbmongo.py
@@ -308,8 +308,8 @@
collection = self.db[table]
if not (fail_on_empty and fail_on_more):
return collection.find_one(db_filter)
- rows = collection.find(db_filter)
- if rows.count() == 0:
+ rows = list(collection.find(db_filter))
+ if len(rows) == 0:
if fail_on_empty:
raise DbException(
"Not found any {} with filter='{}'".format(
@@ -317,8 +317,9 @@
),
HTTPStatus.NOT_FOUND,
)
+
return None
- elif rows.count() > 1:
+ elif len(rows) > 1:
if fail_on_more:
raise DbException(
"Found more than one {} with filter='{}'".format(