mercredi 23 décembre 2020

How make an if where my query == insert whit PYTHON and mongo db?

i know my if recursive query its going to before mi first code line I share a part of my code, where I make my query if not validation and dataDict.keys() > 0:

            #Create object in mongoDB
            clientServiceID = self.clientService.create(dataDict)
            self.db["Driver"].update({"driverID":dataDict['driverID']},{"$set":{"vehicleID":dataDict['vehicleID']}},upsert=False, multi=True)
            self.db["ClientScheduledService"].update({"vehicleID":dataDict['vehicleID']},{"$set":{"driverID":dataDict['driverID']}},upsert=False, multi=True)

            
            if clientServiceID:
                #create activity log
                #self.activityLog.create()
                responseObject["status"] = "OK"
            else:
                #Problem creatin ClientScheduledService
                responseObject["description"] = "Problem creating."
        else:
            #Some parameters are invalid
            responseObject["description"] = "Invalid parameters."


        #Finally end response with JSON
        self.responses.endJSONResponse(self.request, self.response, responseObject)

Aucun commentaire:

Enregistrer un commentaire