How to Delete MongoDB Documents by Importing a File

As of mongoimport version 100.0.0, you can delete documents in MongoDB based on an imported file. To do this, use delete mode.

When you use delete mode, if an imported document has the same _id value as an existing one in the collection that you’re importing into, the existing document will be deleted.

You can also specify another field or fields (other than the _id field) to be the matching field if required.

Continue reading

MongoDB $split

In MongoDB, the $split aggregation pipeline operator divides a string into an array of substrings based on a delimiter.

The delimiter is removed from the string, and the substrings are added as elements to the array.

To use $split, you specify the string and the delimiter.

If the delimiter isn’t found in the string, the original string is returned as the only item in the array.

Continue reading