我定义了一个模式
{
'info' : {
'type' : 'dict',
'unique' : True,
'schema' : {
'propertyA' : {'type':'string'},
'propertyB' : {'type':'string'},
'propertyC' : {'type':'string'}
}
},
'others' : {'type':'string'}
}
然后,我发布以下文档两次,第一次返回OK,第二次返回“notunique error”。你知道吗
[
{
"info" : {
"propertyA" : "a",
"propertyB" : "b",
"propertyC" : "c"
},
"others" : "other things"
}
]
但是当我发布一个文件列表如下:
[
{
"info" : {
"propertyA" : "a",
"propertyB" : "b",
"propertyC" : "c"
},
"others" : "other things"
},
{
"info" : {
"propertyA" : "a",
"propertyB" : "b",
"propertyC" : "c"
},
"others" : "other things"
}
]
这两个文档都被插入到数据库中。
为什么他们有不同的结果?你知道吗
这是因为在第二个场景中,两个文档都将通过一个环回存储到数据库,利用MongoDB的大容量插入功能。因此,当第二个文档根据数据库进行验证时,还没有找到重复的文档。你知道吗
在第一个场景中,您将执行两个单独的保存操作,因此第二个将匹配副本。你知道吗
相关问题 更多 >
编程相关推荐