首页 > 解决方案 > 节点Mysql更新行使用2个条件传递2个参数(ID)

问题描述

我已经用 1 个 id 做了 npoint 并且效果很好,现在我的疑问是如何传递 2 个 id?因为我必须在查询中使用 2 个条件来更新行,而且我也不知道如何制作路线。任何想法,建议?


updateEstadoPatient: (req, res) => {
        const id = req.params.id;
        updateEstadoPatient(id, (err, results) => {
            if (err) {
                console.log(err);
                return;
            }
            if (!results) {
                return res.json({
                    success: 0,
                    message: "Erro ao atualizar o estado do utente"
                })
            }
            return res.json({
                success: 1,
                message: "Estado do utente atulizado com sucesso"

            })
        })
    }



updateEstadoPatient: (id, callBack) => {
        pool.query(
           `UPDATE PEDIDOS_LINHAS SET DATAINI = current_timestamp() WHERE COD_PEDIDO = ? AND  NUMPEDIDO = ?;`,
            [
            [id],
            ],
            (error, results, fields) => {
                if (error) {
                    return callBack(error);
                }
                return callBack(null, results)
            }
        )
    }



router.patch('/patient/:id', updatePatient);

标签: mysqlnode.jsroutes

解决方案


推荐阅读