Brunyan
Brunyan

Reputation: 1

How to change a boolean value in FARM

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

Upvotes: 0

Views: 56

Answers (1)

Belly Buster
Belly Buster

Reputation: 8844

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.

Upvotes: 0

Related Questions