From the course: Polyglot Web Development

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Solution and Perl overview

Solution and Perl overview

From the course: Polyglot Web Development

Start my 1-month free trial

Solution and Perl overview

- [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…

Contents