aboutsummaryrefslogtreecommitdiff
path: root/umosapi/app_db/uobject.py
diff options
context:
space:
mode:
Diffstat (limited to 'umosapi/app_db/uobject.py')
-rw-r--r--umosapi/app_db/uobject.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/umosapi/app_db/uobject.py b/umosapi/app_db/uobject.py
index 9830187..60094c7 100644
--- a/umosapi/app_db/uobject.py
+++ b/umosapi/app_db/uobject.py
@@ -65,3 +65,23 @@ class UObject(object):
mongo.db.uobjects.update_one({"_id": ObjectId(_id)}, {"$set": datas})
return {"msg": "UObject updated.", "code": 200}
return error
+
+ def eq(self, key, value):
+ db = MongoDB(self.app)
+ mongo = db.connection()
+
+ datas = list(mongo.db.uobjects.find(
+ {"datas.{}".format(key): {"$eq": value}}
+ ))
+ if datas:
+ return {
+ "msg": "UObjects found",
+ "datas": datas,
+ "code": 200
+ }
+ else:
+ return {
+ "msg": "UObjects not found",
+ "datas": datas,
+ "code": 404
+ }