簡體   English   中英

如何更改 FARM 中的 boolean 值

[英]How to change a boolean value in FARM

我在創建路由器時遇到問題,該路由器將我的 mongodb 中的 boolean false 值更新為 true。所有這些都是通過我前端的按鈕激活的。

`@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}
    #    )`

我已經嘗試了很多變體,並收到 500 http 錯誤

update_one()有兩個參數; 過濾器和更新。 您錯過了過濾器並將更新傳遞給過濾器參數。

這將在某處記錄為異常; 您應該嘗試找出控制台 output 的去向,否則很難追蹤這些問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM