更新时间:2022-11-13 22:30:00
这@Disposer回答帮我找到了一个解决方案。它传播的多个领域,我的代码库,但我想与他人分享的基本精神谁可能有类似的问题。
Answer from @Disposer helped me find a solution for this. It spreads multiple areas in my codebase but I would like to share the basic gist with others who may have a similar problem.
这些步骤如下:
WriteCount
字段的组合,并使用 findAndModify
以原子更新文档仅当它尚未在此期间被更新(更新,如果当前)。WriteCount
field and by using findAndModify
to atomically update the document only if it has not been updated in the meantime ("update if current").然后,当更新标题
对于给定的项目:
Then, when updating Title
for a given item:
WriteCount
$
来标识会话,一个整数首页
为目标的项目,同时聘请更新,如果目前的战略使用 WriteCount
字段WriteCount
$
to identify the session, an integer index
to target the item, while employing "update if current" strategy using the WriteCount
field.然后将更新的部分就变成了:
The update part then becomes:
"Sessions.$.Order.Items." + index + ".Title"