Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Suggest that you install express(in addition to node.js and mongoose) and follow a guide/tutorial with that. Express will allow you to use a REST-like approach. </p> <pre><code>npm install -g express </code></pre> <p>From your app.js (application setup file) you define your routes and define which methods/REST calls each route belongs to. </p> <p>I can show you an example for deleting:</p> <p>In my app.js:</p> <pre><code>app.post('/deleteActivity', activityList.deleteActivity.bind(activityList)) </code></pre> <p>Tells the application that posts to /deleteActivity will be handled in activityList with the method deleteActivity. </p> <p>In my activityList.js:</p> <pre><code> deleteActivity: function(req,res) { var item = req.body.item; var deleted = item.activity; activity.remove({_id: deleted}, function(err){ if(!err){ console.log('Deletes ' + item.activity); } else { console.log('Could not delete' + item.activity); } }); res.redirect('/'); } </code></pre> <p>req.body.item here contains all the data needed to delete the activity. This is sent from my index.jade file like this:</p> <pre><code>form(action="/deleteActivity", method="post") select(name = "item[activity]") each activity in activities option(value=activity._id) #{activity.activityType} input(type="submit", value="Delete activity") </code></pre> <p>As you can see, the data gets binded to the request with the values provided by the user. In this case activity._id is passed to deleteActivity.</p> <p>In your case, just make a new object of your desired Schema(mongoose) and use the save method on it.</p> <p>Hope this helps</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload