I have the below doc in DB:
{
"_id": {
"$oid": "6475dd3485054c30333cf52c"
},
"job_queue_name": "CURIE_BLR",
"job_job_id": 1059,
"job_jenkins_job_id": 0,
"job_status": "ENQUEUED",
"job_platform_name": "FUGAZI",
"job_branch": "master",
"job_json": "fugazi_imix_profiles",
"job_email_id": "akshjosh@cisco.com",
"job_profiles_to_run": "IPSEC_MCAST-imix_1400,IPSEC_QOS_DPI_FNF_MCAST-imix_1400",
"job_qt_mode": "prod",
"job_baseline": "none",
"job_no_of_trials": "1",
"job_cycle": "1",
"job_type": "UP",
"job_submitted_time": {
"$date": "2023-05-29T07:15:43.825Z"
},
"job_start_time": {
"$date": {
"$numberLong": "-62135596800000"
}
},
"job_end_time": {
"$date": {
"$numberLong": "-62135596800000"
}
},
"job_results": "NA"
}
I want to update the job_jenkins_job_id and job_status. Using the below code but its not updating. No error is also thrown.
I want to make sure that the update happens and I get the count of updated docs. How to achieve this?
myclient = pymongo.MongoClient("mongodb://10.64.127.94:27017/")
mydb = myclient["UPTeam"]
mycol = mydb["perf_sdwan_queue"]
myquery = {"$and":[
{"job_job_id":{"$gt":"{}".format("1059")}},
{"queue_name":{"$gt":"CURIE_BLR"}}
]}
newvalues = { "$set": { "job_jenkins_job_id": 12, "job_status": "RUNNING" } }
mycol.update_one(myquery, newvalues)
myquery is not returning anything.
I think your query is just wrong, so there are no matching items.
Try
myquery = {
"$and": [
{"job_job_id": 1059},
{"queue_name": "CURIE_BLR"},
]
}
instead...