O'Reilly logo

Hands-On Full Stack Web Development with Aurelia by Erikson Haziz Murrugarra Sifuentes, Diego Jose Arguelles Rojas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Deleting teams

Deleting a team is extremely easy. To do this, we will call the remove built-in method of the Team model. Add the following code:

....delete((req, res, next) => {    let id = req.params.id    Team.remove({_id: id})      .then(result => res.json(result))      .catch(err => next(err))  })module.exports = api

Now, let's test things out. Execute the following command:

$ curl -X DELETE http://localhost:3000/teams/5a662fbf728726072c6298fc{"n":1,"ok":1}

The output is a bit different now; we received a JSON object with two params:

  • n: The number of documents removed
  • ok: 1 if the operations were successful or 0 if not

Awesome! Now we have our Rest API to manage our teams ready, but there is a key missing piece in our API that we did not take care of, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required