今天集合的字段做了修改,原来的字段不想要了,记录一下处理方法
db.你的Collection.update({}, {$unset: {你的field:1}}, false, true);
假设原文档如下
{
name: 'book',
tags: {
words: ['abc','123'],
lat: 33,
long: 22
}
}
期望的新文档如下
{
name: 'book',
tags: {
lat: 33,
long: 22
}
}
那么删除 words 的命令应该是这样的
db.example.update({}, {$unset: {words:1}}, false, true);