Another method is Todo.findByIdAndRemove. The findByIdAndRemove method works just like findById: you pass in the ID as the argument and it removes it. Now, both of these are going to return the doc and that is exactly what we want. There's no need to run both of them, we can just run one. TheĀ Todo.findByIdAndRemove method, this is going to let us remove a Todo ById, some ID like asdf, and we're going to be able to attach a then method providing our callback, and the callback is going to get the doc back. You could call it doc, or in this case we can call it todo since it is a Todo item:
Todo.findByIdAndRemove('asdf').then((todo) => {
});
Now that we have this in place, we just need to create a Todo, since we deleted all of them, and include the ID. Over inside of Robomongo I can right-click that todos collection and insert a document. We're just going to set a text property and I'll set that text property equal to Something to do, and we can save that record. I'm going to make sure that when I click View Documents we do get our one document:

Now obviously it is missing some of the properties since I created it in Robomongo, but that is fine for our purposes. I'm now going to edit that document and grab the ID, and this is the ID we can add in to our playground file to make sure the document gets removed. Over inside of Atom, in theĀ findByIdAndRemove method, we'll pass in our string. This is the string ID, and inside of our then callback we're going to use console.log to print the todo to the console. I am going to comment out this call to remove previous because otherwise it would remove the document we're trying to remove:
//Todo.remove({}).then((result) => {
// console.log(result);
//});
Todo.findByIdAndRemove('5aa8b74c3ceb31adb8043dbb').then((todo) => {
console.log(todo);
});
With this in place, I can now save the file, head into the Terminal, and rerun the script. I'm going to shut it down and start it up again:

We get our documents, which is fantastic, and if I head into Robomongo and try to fetch the documents in todos, we're going to get an error that there are no documents; we had one but we deleted it. Now, inside of Atom we can also play around with findOneAndRemove. The findOneAndRemove method works exactly the same as findByIdAndRemove, only it takes that query object. This would be Todo.findOneAndRemove; we would pass in the query object like this, pasting in our ID, and we could attach our then callback, which would get called with the document:
Todo.findOneAndRemove({_id: '57c4670dbb35fcbf6fda1154'}).then((todo) => {
});
Both of these work very similarly, but the big difference is whether or not you need to query by more than just the ID. Now that you know how to use findByIdAndRemove, we're going to go into the server file and start filling out the actual route. This is going to be the route that lets us delete a Todo. I'll do the setup for the route for you, but you're going to be responsible for filling out everything inside of the callback function.