I have following query in my database
query = u'collection.aggregate([{ "$match": { "code": { "$in": {__sensors__}} } },{"$project" : {"_id" : 0}},{"$group" : {"_id": "$code", "data": {"$last": "$$ROOT"}}}])'
And I have following arguments, Now I want to pass that argument in the above query.
args = {"__sensors__": ["GP0", "GP1", "GP5", "GP6"]}
I'm trying following but it is giving me an error.
query.format(**args)
above statement giving me this error
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-44-7db1aba33ea5> in <module>()
----> 1 a.query.format({"__sensors__": []})
KeyError: u' "$match"'
Can anyone give me the solution for the above problem?