doulierong0334 2014-03-20 23:41 采纳率: 100%
浏览 24

查询相同类型的根实体和子实体时,数据存储区是否需要指定祖先?

For example, take the following snippet from the provided appengine-angular-gotodos :

func getAllTodos(c appengine.Context) ([]Todo, error) {
    todos := []Todo{}
    ks, err := datastore.NewQuery("Todo").Ancestor(defaultTodoList(c)).Order("Created").GetAll(c, &todos)
    if err != nil {
        return nil, err
    }
    for i := 0; i < len(todos); i++ {
        todos[i].Id = ks[i].IntID()
    }
    return todos, nil
}

If you change the query to not include .Ancestor(defaultTodoList(c)). the function fails to return any todo results.

  • If an entity is saved with an ancestry, must you query it by that ancestor?
  • How do you query for Entities regardless of whether they are children, or root entities?
  • What are the performance and architecture considerations I should make when modeling my app given the need to do ancestor-less queries?
  • 写回答

2条回答 默认 最新

  • dphs48626 2014-03-21 03:20
    关注

    defaultTodoList(c) might not contain the parent Entity that the code expects it to contain. Try to verify its value somehow before using it, for example by storing it in a variable and then logging data out of it.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题