I'm trying to find the global result (calendar) by ID and find nested results in the calendar by another ID.
If I use find function - it's work for me (found exactly what I need)
calendar_data.find({'calendar_id': calendar_id}, {'calendar_results': {'$elemMatch': {'results_id': results_id}}})
But if I use update function - I get the error:
calendar_data.update({'calendar_id': calendar_id},
{'calendar_results': {'$elemMatch': {'results_id': results_id}}},
{'$addToSet': {'calendar_results.$.results': new_results}})
TypeError: upsert must be True or False
If I add upsert=True I get another error:
TypeError: update() got multiple values for argument 'upsert'
What I'm doing wrong? How to append new_results to founded calendar_results?
My data structure looks like that:
"calendar_results":[
{
"checkin":"2020-01-18",
"checkout":"2020-01-19",
"results_id":"2a2f3199-98b6-439d-8d5f-bdd6b34b0fd7",
"guests_number":0,
"pets_allowed":0,
"days_count":1,
"query":"My Query",
"results":[
{
"id":5345345,
"name":"My name",
"reviews_count":5,
"avg_rating":5.0,
"rate_per_night":75.0,
"cleaning_fee":10.0,
"service_fee":0,
"price_per_night":75.0,
"total_price":85.0,
"checkin":"2020-01-18",
"checkout":"2020-01-19",
"query":"Test",
"position":1
},
{
"id":312312312,
"name":"Some name",
"reviews_count":111,
"avg_rating":4.93,
"rate_per_night":57.0,
"cleaning_fee":7.0,
"service_fee":0,
"price_per_night":57.0,
"total_price":64.0,
"checkin":"2020-01-18",
"checkout":"2020-01-19",
"query":"Test",
"position":2
}
]
}
]