Deleting a key/value from existing MongoDB entry

Try $unset in a call to update().

Like this:

db.collection_name.update({ _id: 1234 }, { $unset : { description : 1} })

And, as vikneshwar commented, if you want to remove one field from all (or multiple) documents you can use updateMany() like this:

db.collection_name.updateMany({}, { $unset : { description : 1} })

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)