0%

在 MongoDB Collection 內完全移除一個 Field

Remove mongodb field from collections

1
2
3
4
5
6
7
8
{ 
name: 'book',
tags: {
words: ['abc','123'],
lat: 33,
long: 22
}
}

db.example.update({}, {$unset: {tags.words:1}}, false, true);
remove words

1
2
3
4
5
6
7
{ 
name: 'book',
tags: {
lat: 33,
long: 22
}
}

StackOverflow : How to remove a field completely from a MongoDB document?