【问题标题】:How to delete an entity by property in gae datastore如何通过 gae 数据存储中的属性删除实体
【发布时间】:2013-05-08 23:25:12
【问题描述】:
Key newwordKey = KeyFactory.createKey(NEWWORD_KEY_KIND, NEWWORD_KEY);
Entity newWord = new Entity(NEWWORD_ENTITY_KIND, newwordKey);
newWord.setProperty(USER_COL_USERNAME, userName);
newWord.setProperty(NEWWORD_COL, word);
datastore.put(newWord);

我的意思是我想通过其属性“用户名”删除所有“新词”实体 例如,删除用户“Alexis”上传的所有单词 任何想法 ?谢谢

【问题讨论】:

    标签: google-app-engine google-cloud-datastore


    【解决方案1】:

    使用按查询删除实体功能:

    Query q = pm.newQuery(NEWWORD_KIND.class);
    q.setFilter("USER_COL_USERNAME == USR");
    q.declareParameters("String USR");
    q.deletePersistentAll("Alexis");
    

    More info here

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-29
      相关资源
      最近更新 更多