How to delete appengine data using Go?

huangapple go评论85阅读模式
英文:

How to delete appengine data using Go?

问题

我正在尝试使用查询从数据存储中删除一些数据。基本上,我想删除除了 Owner="x" 的一个 Product 实体之外的所有 Product 实体。然而,Delete 函数似乎只接受一个 Key 作为参数。我应该如何根据查询来实际删除数据呢?

英文:

I'm trying to delete some data from datastore using a query. Basically I want to delete all the Product entities except one with the Owner="x" . However the Delete function seems to accept only a Key as argument. How am I supposed to actually delete based on a query ?

答案1

得分: 1

首先,您需要使用查询来获取您想要删除的所有实体。使用仅键查询来最小化成本。

然后执行批量删除,以一次删除多个实体。

根据数据集的大小,您可能需要使用推送任务队列,该队列具有10分钟的时间限制。

英文:

First you will have to use a query to get all entities you want deleted. Use keys-only query, to minimize the cost.

Then perform batch delete, to delete multiple entities at once.

Depending on dataset size, you might need to use push Task Queue, which have 10min time limit.

huangapple
  • 本文由 发表于 2014年8月9日 22:18:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/25219471.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定