The deleteOne method

The goal here is to use deleteOne to delete the document where the text equals Eat lunch, but since we're using deleteOne and not deleteMany, one of these should stay around and one of them should go away.

Back inside of Atom, we can go ahead and get started by calling db.collection with the collection name we want to target. In this case it's Todos again, and we're going to use deleteOne. The deleteOne method takes that same criteria. We're going to target documents where text equals Eat lunch.

This time though, instead of deleting multiple documents we're just going to delete the one, and we are still going to get that same exact result. To prove it, I'll just print to the screen like we did previously with console.log(result) ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.