$or queries replaced with $in which is much easier to read in code and prepare

This commit is contained in:
iLLiCiTiT 2019-11-05 10:33:17 +01:00
parent 4dee025cfe
commit 0af320f9f7
3 changed files with 3 additions and 9 deletions

View file

@ -277,10 +277,7 @@ class DeleteAsset(BaseAction):
'message': 'No entities to delete in avalon'
}
or_subquery = []
for id in all_ids:
or_subquery.append({'_id': id})
delete_query = {'$or': or_subquery}
delete_query = {'_id': {'$in': all_ids}}
self.db.delete_many(delete_query)
return {

View file

@ -97,10 +97,7 @@ class AssetsRemover(BaseAction):
'message': 'None of assets'
}
or_subquery = []
for id in all_ids:
or_subquery.append({'_id': id})
delete_query = {'$or': or_subquery}
delete_query = {'_id': {'$in': all_ids}}
self.db.delete_many(delete_query)
self.db.uninstall()

View file

@ -562,7 +562,7 @@ def get_subsets(asset_name,
find_dict = {"type": "representation",
"parent": version_sel["_id"]}
filter_repr = {"$or": [{"name": repr} for repr in representations]}
filter_repr = {"name": {"$in": representations}}
find_dict.update(filter_repr)
repres_out = [i for i in io.find(find_dict)]