google app engine ndb: put() and then query(), there is always one less item

前端 未结 5 1798
走了就别回头了
走了就别回头了 2021-01-11 20:36

I wonder if anybody has encountered the strange problem on Google App Engine\'s NDB: after creating a new entity and saving it by put(); and then query()<

5条回答
  •  粉色の甜心
    2021-01-11 21:26

    This is expected behaviour; your queries above are only eventually consistent. That is, you're not guaranteed to get the very latest results when querying.

    You can get around this by using an ancestor query (see the link above). For your example, you'd need to give each of your items a parent entity and then use Item.query().ancestor(theParentEntity).fetch().

提交回复
热议问题