我最近在端点上工作,遇到一个问题:猫鼬不会更新条目。
export const playersTurn = async (
req: Request,
res: Response,
next: NextFunction
) => {
try {
[...]
let symbol: 'X' | 'O';
room.roomPlayers.forEach((player) => {
if (player.id === id) symbol = player.symbol;
});
room.board[row][column] = symbol;
room.save();
res.status(201).json({
message: 'Your turn has been registered!',
status: 201,
});
} catch {
return next({
status: 500,
message: 'Unexpected error occured!',
});
}
};
这也是架构,
const roomSchema = new Schema(
{
[...]
board: [
[String, String, String],
[String, String, String],
[String, String, String],
],
[...]
},
{ timestamps: true }
);
有人可以解释一下,这为什么不起作用?预先感谢。
答案 0 :(得分:0)
您需要在代码中添加一个等待状态
await room.save();
答案 1 :(得分:0)
使用了mvn test -TC
。现在可以使用。