Why do I get Only ancestor queries are allowed inside transactions error

☆樱花仙子☆ 提交于 2019-12-05 09:19:25

No way to do ancestor-less query inside a transaction. Either you do it without transactions or replace query with get.

The closest that you can do is:

  1. Get entity with ancestor-less query without transaction. Remember key of the entity.
  2. Start transaction.
  3. Get entity via the key.
  4. Check that query condition still applies (= properties still have the same values as in query conditions). This way you can be sure entity was not changed since you did the query.
  5. Change & save entity. Commit transaction.

The error seems quite clear: inside a transaction, you're only allowed to perform ancestor queries. Your query is not an ancestor query.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!