Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用nodejs和mongodb更新方法_Javascript_Node.js_Mongodb - Fatal编程技术网

Javascript 使用nodejs和mongodb更新方法

Javascript 使用nodejs和mongodb更新方法,javascript,node.js,mongodb,Javascript,Node.js,Mongodb,因此,我正在尝试更新项目中的一个事件,到目前为止,我有点让它工作,我可以看到我在cmd中输入的输入,但数据没有存储在mongodb中。一旦我按下“提交”按钮,我就会被重定向到一个显示“未找到”的页面 这是“我的更新事件”页面的代码 <div class = "row"> <div class="col-md-4 col-md-offset-4"> <h1> Update Event</h1> {{#i

因此,我正在尝试更新项目中的一个事件,到目前为止,我有点让它工作,我可以看到我在cmd中输入的输入,但数据没有存储在mongodb中。一旦我按下“提交”按钮,我就会被重定向到一个显示“未找到”的页面

这是“我的更新事件”页面的代码

<div class = "row">
    <div class="col-md-4 col-md-offset-4">
            <h1> Update Event</h1>
        {{#if hasErrors}}
            <div class=alert alert-danger">
                {{# each messages}}
                    <p>{{this}}</p>
                {{/each}}
            </div>
        {{/if}}

        <form action=/user/updateEvents/{{this._id}} method="post">
            <div class="form-group">
                <label for="eventName">Event Name</label>
                <input type="text" id="eventName" name="eventName" class="form-control">
            </div>

            <div class="form-group">
                <label for="eventDate">Event Date</label>
                <input type="text" id="eventDate" name="eventDate" class="form-control">
            </div>

            <div>
                <label for="eventPlace">Place of Event</label>
                <input type="text" id="eventPlace" name="eventPlace" class="form-control">
            </div>

            <div>
                <label for="eventPrice">Price of Event: €</label>
                <input type="text" id="eventPrice" name="eventPrice" class="form-control">
            </div>

            <input type="hidden" name="_csrf" value="{{csrfToken}}">
           <button type="submit" class="btn btn-success">Update Event</button>
        </form>
</div>
这是我的活动路线

    //store the updated data in to the database 
router.post('/updateEvents',updateEvents, function(req, res, next) {
});
任何帮助都将不胜感激。
谢谢。

它是否在您的控制台中记录了任何内容?您将它作为路径参数发送,但您的服务器端中间件定义不包括动态部分。你能试试路由器.post('/updateEvents/:id',…?另外,这是安装在“/user”上的路由器吗?否则你也需要包括它。所以当我有路由器.post时(“/updateEvents/:id”“,…在cmd中,数据没有显示,但当我删除它时,数据会显示。它是否在控制台中记录了任何内容?您将其作为路径参数发送,但您的服务器端中间件定义不包括动态部分。您是否可以尝试
router.post(“/updateEvents/:id”“,
)?另外,这是安装在“/user”?否则您也需要包含它。因此,当我在cmd中有router.post(“/updateEvents/:id”…)时,数据不会显示,但当我删除它时,数据会显示。
    //store the updated data in to the database 
router.post('/updateEvents',updateEvents, function(req, res, next) {
});