Answers for "mongodb remove field from collection"

13

remove property mongodb

db.myCollection.update({}, {$unset: {fieldToRemove:1}} , {multi: true});
Posted by: Guest on May-25-2020
0

how to remove field from document in mongodb

=> Use the $unset field update operator to completely remove a field from a document.
{ $unset: { "field_name": "value" } }

=> You can specify multiple fields to remove by separating them with a comma.
{ $unset: { name: "", weight: "" } }
Posted by: Guest on June-09-2021
0

mongodb delete document where field exists

db.users.remove({
    "$or": [
        { "firstName": { "$exists": false } },
        { "lastName": { "$exists": false } }
    ]
})
Posted by: Guest on November-04-2020

Code answers related to "mongodb remove field from collection"

Code answers related to "Javascript"

Browse Popular Code Answers by Language