代码之家  ›  专栏  ›  技术社区  ›  David Haddad

是否可以在不知道元素属于哪个集合的情况下按键查询Firestore中的元素?

  •  2
  • David Haddad  · 技术社区  · 8 年前

    使用AngularFire2、Angular、Firebase Firestore和我的一个记录来建模用户和不同类型对象之间的关系。

    /*
    Represents a reaction that a user has towards some object in the system.
    */
    export interface Reaction{
    
    // The id of the user making that reaction
    userId? : string;
    
    // The id of the object that is being reacted to. Place, Org, List, Offer
    objectId? : string;
    
    }
    

    正如您所见,存储的唯一内容是对象的键,而不是其类型或它所属的集合。我想知道以后怎么可能查询这些反应,然后从那里得到纯粹基于键的对象?

    1 回复  |  直到 8 年前
        1
  •  3
  •   Doug Stevenson    8 年前

    您必须知道文档集合(可能还有子集合)的名称才能获取它。没有查询概念可以在不知道集合的情况下获取文档。