Couchbase 将子文档升级为带有mutate_的列表

Couchbase 将子文档升级为带有mutate_的列表,couchbase,upsert,mutation,subdocument,Couchbase,Upsert,Mutation,Subdocument,非常感谢你在这里的帮助 我试图通过在中使用mutate_对子文档进行变异,然后用我要放入的每个元素的路径定义SD。 代码如下所示: 这就是它带来的结果: 我想要的是这个(注意,我把它放在这里的列表中): 一旦我能够实现上述列表,我应该能够生成多个子文档,如下所示: 请注意,现在我在这个列表中有两个元素,它们都有不同的值: 问题: can I achieve this with mutate_in and SD.upsert ? if so, how can I change that c

非常感谢你在这里的帮助

我试图通过在中使用mutate_对子文档进行变异,然后用我要放入的每个元素的路径定义SD。 代码如下所示:
这就是它带来的结果:
我想要的是这个(注意,我把它放在这里的列表中):
一旦我能够实现上述列表,我应该能够生成多个子文档,如下所示:

请注意,现在我在这个列表中有两个元素,它们都有不同的值:
问题:

can I achieve this with mutate_in and SD.upsert ?
if so, how can I change that code I have provided at the beginning of this thread to put things in a list
Once I can put it as a list, how can I avoid upsert not overwriting the record but to attach another record in that list?
非常感谢你的帮助。谢谢大家!


期待所有couchbase大师的指导,您可以创建一个表示新JSON对象的Python字典,并将其附加到数组中(
create\u parents=True
说“如果数组不存在,则创建数组”)

我不精通Python,也不知道这是否可以编译。。。所以我们称之为伪代码:-)


通过这种方式,一次最多可以追加16个项目(子文档批处理限制为16个操作)。

您使用的是Couchbase Python SDK吗?是的,我使用的是Couchbase Python SDK
{
“strat”: {
“a”: 76543,
“b”: “true”,
“c”: 30,
“d”: -25,
“e”: “C”,
“f”: 7
}
}
{
“Strat”: [
{
“a”: “12345”,
“b”: 7,
“c”: “C”,
“d”: “true”,
“e”: -25,
“f”: 25
}
]
}
{
“Strat”: [
{
“a”: “12345”,
“b”: 7,
“c”: “C”,
“d”: “true”,
“e”: -25,
“f”: 25
},
{
“a”: “34567”,
“b”: 8,
“c”: “F”,
“d”: “false”,
“e”: -30,
“f”: 40
}
]
}
can I achieve this with mutate_in and SD.upsert ?
if so, how can I change that code I have provided at the beginning of this thread to put things in a list
Once I can put it as a list, how can I avoid upsert not overwriting the record but to attach another record in that list?
cb.mutate_in(‘1_2’,
    SD.array_append('strat',
        {
            "a": "12345",
            "b": 7,
            "c": "C",
            "d": "true",
            "e": -25,
            "f": 25
        },
        create_parents=True),
   
    SD.array_append('strat',
        {
            // some other values...
        },
        create_parents=True));