How to delete multiple columns (fields) from a MongoDB Collection

MongoDB is not SQL. There can be a schema to enforce types, but often there is no schema. You essentially have to update all the documents in the collection.

db.yourcollectionname.updateMany({}, {
    $unset: {
        'field1': 1,

I believe the value of “1” is used after each field just because they use JSON, and each JSON field has to have some value.

Leave a Reply

Recent Posts




All Rights Reserved Theme by 404 THEME.