数据存储模式下 google 云火存储中实体组对事务的影响
The effect of entity group on transaction in google cloud firestore in datastore mode
我是 Google 数据库模式 Cloud Firestore 的新手,我对其事务有疑问。
如果有两个实体属于同一个实体组,一个实体在一个事务上的更新是否会抑制另一个实体在另一个事务上的更新?
我在下面展示了一个示例。
Entity A:
Key:
Kind: Foo, id: 0, Parent: "P"
Properties:
description: "I am A."
Entity B:
Key:
Kind: Foo, id: 1, Parent: "P"
Properties:
description: "I am B"
TRANSACTION #1 BEGIN;
A.description = "I am new A";
TRANSACTION #2 BEGIN;
B.description = "I am new B";
TRANSACTION #1 COMMIT; -- *1
TRANSACTION #2 COMMIT; -- *2
*1或*2是否成功?
谢谢!
If there are two entities which belong to the same entity group, does an update of one entity on a transaction inhibits an update of the other entity on another transaction?
不,这与 OR
无关,与 AND
无关,因此两个事务都将被提交。据我从您的架构中了解到,您尝试使用事务来更新两个单独的文档,这将始终有效。即使您尝试更新同一个文档,它也将始终有效,提交的顺序是您在事务对象上调用 commit()
的顺序。所以你的提交结果将是:
Entity A:
Key:
Kind: Foo, id: 0, Parent: "P"
Properties:
description: "I am new A."
Entity B:
Key:
Kind: Foo, id: 1, Parent: "P"
Properties:
description: "I am new B"
我是 Google 数据库模式 Cloud Firestore 的新手,我对其事务有疑问。
如果有两个实体属于同一个实体组,一个实体在一个事务上的更新是否会抑制另一个实体在另一个事务上的更新?
我在下面展示了一个示例。
Entity A:
Key:
Kind: Foo, id: 0, Parent: "P"
Properties:
description: "I am A."
Entity B:
Key:
Kind: Foo, id: 1, Parent: "P"
Properties:
description: "I am B"
TRANSACTION #1 BEGIN;
A.description = "I am new A";
TRANSACTION #2 BEGIN;
B.description = "I am new B";
TRANSACTION #1 COMMIT; -- *1
TRANSACTION #2 COMMIT; -- *2
*1或*2是否成功?
谢谢!
If there are two entities which belong to the same entity group, does an update of one entity on a transaction inhibits an update of the other entity on another transaction?
不,这与 OR
无关,与 AND
无关,因此两个事务都将被提交。据我从您的架构中了解到,您尝试使用事务来更新两个单独的文档,这将始终有效。即使您尝试更新同一个文档,它也将始终有效,提交的顺序是您在事务对象上调用 commit()
的顺序。所以你的提交结果将是:
Entity A:
Key:
Kind: Foo, id: 0, Parent: "P"
Properties:
description: "I am new A."
Entity B:
Key:
Kind: Foo, id: 1, Parent: "P"
Properties:
description: "I am new B"