How to change a boolean value in FARM

50 views Asked by At

I am having an issue creating a router that updates a boolean false value to true in my mongodb. All of this is activated by a button on my front end.

    @router.post("/started", response_description="start fight")
    async def update_started(request: Request, started: bool):
        start = await request.app.mongodb["matches"].update_one({"$set": {"started": True}})
        return start

    
    #@router.put("/update", response_description="start fight")
    #async def update_started(started: bool, request: Request):
     #   if started == False:
       #     started = request.app.database["matches"].update_one(
         #       {"started": False}, {"$set": True}
        #    )

I've tried many variations of this and am getting a 500 http error

1

There are 1 answers

0
Belly Buster On

update_one() takes two parameters; a filter and an update. You've missed off the filter and passed the update to the filter parameter.

This will be logged as an exception somewhere; you should try and find out where the console output goes otherwise tracking these issues down will be hard.