gpt4 book ai didi

javascript - Marklogic 服务器端 Javascript : XDMP-CONFLICTINGUPDATES while using explicit commit

转载 作者:行者123 更新时间:2023-11-30 11:27:23 27 4
gpt4 key购买 nike

我一直遇到 Marklogic 更新冲突的问题。我知道原因,但我不知道如何解决。我有一个主 (.sjs) 文件,它调用两个不同的 (.sjs) 文件,这两个文件都更新了一组文档。在主文件中,我使用:declareUpdate({explicitCommit: true}); 然后在单独的文件中,我在更新文档后使用命令 xdmp.commit(); .但是,我仍然收到:XDMP-CONFLICTINGUPDATES

部分代码:Main.sjs:

function main(){
declareUpdate({explicitCommit: true});
function.to.file.1();
function.to.file.2();
}

文件 1.sjs:

//make some docs and insert them into ML
function file1Function(){
for (let d of someCollectionOfData) {
xdmp.documentInsert('/a/uri/filexx.json', d, {collections: aCollectionName1});
};
xdmp.commit();
}

文件2.sjs:

//adjust docs made in file1 and put them back into ML
funtion file2Function(){
for (let d of xdmp.directory('/location/of/aCollectionName1/','infinity')) {
let dObj = d.toObject();
dObj.addSomething = 'something';
xdmp.documentInsert(fn.documentUri(d), dObj, {collections: aCollectionName1});
}
xdmp.commit();
}

最佳答案

这一定意味着您的 file1 位于“/location/of/aCollectionName1/”内。请记住,当您调用 xdmp.commit() 时,MarkLogic 不会立即提交。实际的持久化总是推迟到所有代码执行完之后。因此,在一个请求中多次调用 xdmp.commit() 没有多大意义。在 xdmp.commit() 之后您将无法阅读您的更新。

喂!

关于javascript - Marklogic 服务器端 Javascript : XDMP-CONFLICTINGUPDATES while using explicit commit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47507760/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com