Learn the solutions for the DELETE challenge, and receive an overview of Perl.
- [Instructor] I hope you found…the delete implementation straightforward…from what I've been going over.…For the quick functions I think Perl's got a nice syntax…and it's easy to follow.…Of course I did program in Perl for 15 years…so I forgive you if you don't agree.…I'm actually going to show you…a couple of different ways to do this…because in Perl there's more than one way to do it.…In this case one is definitely better, but they both work.…So first, the simple answer,…which you could build from the top as we've already covered.…Use the same code we use to get a single quote…and if it's not there, send a 404,…and if it is there, delete it.…
It's pretty straightforward.…But maybe you want to do this…in a slightly more efficient way.…It turns out that the mongo driver delete one method…returns an object with an attribute of deleted count.…So I'll use that to determine if we should tell the caller…that the document just didn't exist.…So we're going to call the delete one,…we check the deleted count, if it's zero we send a 404,…
- Why become a polyglot programmer?
- Exploring Node.js, Python, Perl, and Ruby code
- Building on prior knowledge to learn new programming languages
- Learning API read and write functionality in Node.js, Python, Perl, and Ruby
- Implementing API functionality in Node.js, Python, Perl, and Ruby
Skill Level Intermediate
Building APIs Using Hapi in Node.jswith Kirsten Hunter2h 23m Intermediate
1. Becoming a Polyglot
Next steps1m 19s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.