英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论