I am trying to query a very tangled collection.
The schema:
{'tags': {'variables': [{'value': '3x9', 'var_name': 's'},{'value': '12:00AM', 'var_name': 'x'},{'value': 'goog', 'var_name': 'y'}]},'url': 'https://www.google.com'}]
The Query:
res = mycol.aggregate([{"$unwind":"$tags"},{'$match': {'tags.tag.name':'A A', 'aR': 98765}},{'$project': {'url': 1, 'tags.vars': 1, '_id': 0}},])res = list(res)
for x in res: print(res)
The Result:
{'tags': {'variables': [{'value': '3x9', 'var_name': 's'},{'value': '12:00AM', 'var_name': 'x'},{'value': 'goog', 'var_name': 'y'}]},'url': 'https://www.google.com'}]
The Expected Result:
[{'value': '3x9', 'var_name': 's'},
{'value': '12:00AM', 'var_name': 'x'},
{'value': 'goog', 'var_name': 'y'},
'url': 'https://www.google.com']
I will use it as a HttpResponse
and use it as a JSON
object.
Please Help!