2
我一直在从MongoDB文档中的数组中删除一个字符串的问题的麻烦。例如,我想从下面的文档的列表字段中删除条目“四”。如何从mongodb文档中的数组中删除字符串?
{
"list" : [ "1", "2", "four", "five", "6"]
}
我知道这似乎很简单,但我一直无法从文档或以前的问题找到直接的答案。我已经尝试了5个左右的命令,无法使用db.collection.update与$ pull和$ mod修饰符结合使用。任何帮助?
我知道,非常基本的问题。
我觉得你的问题是重复的 - >看http://stackoverflow.com/questions/10146735/deleting-a-key-value-from-existing-mongodb-entry – B4NZ41
尝试'pull'像这样'update({},{“$ pull”:{“list”:“four”}})' – Yogesh
[Removing specific i从数组与MongoDB的](http://stackoverflow.com/questions/9048424/removing-specific-items-from-array-with-mongodb) –