Monday, 24 April 2017

Mongo DB not updating, without error

Trying to update the below M Lab hosted mongo DB, not much luck, any ideas? Form input via handlebars template, routed to express server. No errors, and DB does not update.

{ "_id": { "$oid": "58fdec20a8aac60a190152ae" }, "name": "Item1", "status": 0 }

app.put("/:id", function(req, res) {

    db.collection.update({_id: req.body.id}, 
        {
            $set:{status: 1}, function(){
            res.redirect("/");
            console.log('updated')
            }
    });

}); 
<ul> Let's Eat
  
    <li> 
      <p>
        <form action="/:?_method=PUT" method="POST">
          <input type="hidden" name="id" value="">
          <button type="submit">Update</button>
        </form>
      </p>
    </li>
  
</ul>


via mjr_river

No comments:

Post a Comment