Access mongo CLI

Show databases

Show Collections

Filter Unique Values

Filter unique values (only the values) from a column (first you must «use db», only change «collection» and «column» do not change the db prefix)

Filter Unique Values on duplicated elements and show all the fields of the document

I had to filter an specific field, for example:

(Yes, the same data is inserted over and over again with certain variations on other fields, but each MACAddress is unique).

And I would like to return:

So,

Filter the unique values using .unique()

  1. do a (for) loop over that values

Remove fields from all documents

Backup mongodb

This is the Recommended method by mongo

If you receive this error, be sure you are in a path with write access:

So a dump folder will be created with all the binary data of your mongoDB:

Restore mongodb

After using mongodump you can restore easily by using mongorestore and the directory name where is your backup, here «dump» is the default name of the directory after executing mongo restore:

Delete documents with empty fields