Advanced Node.js Development
上QQ阅读APP看书,第一时间看更新

The deleteOne Method

Now, aside from deleteMany, we have deleteOne, and deleteOne works exactly the same as deleteMany, only it deletes the first item it sees that matches the criteria and then it stops.

To illustrate exactly how this works, we're going to create two items inside of our collection. If I give things a refresh, you will see that we now only have two documents:

These are the ones we started with. I'm going to insert documents again using the same data that's already in my clipboard. This time we'll just make two document, two that are identical.