如何建模NOSQL数据库(Firestore)?查看我的第一种方法



我试图为我的第一个NOSQL数据库(firestore)建模,以反映民主组织(例如当事方)关于思想的决定。

因此,如果您可以回顾我的NOSQL概念并给我有关如何改进它的提示,我将非常感谢。如果您喜欢这个想法,如果您想支持该项目,请查看Git-Repo:https://github.com/donnerstagnacht/leftlife

所以,我考虑了一个具有以下属性的民主思想模型:

    // attributes of the idea
    ideaID: string;
    location: string;
    image: string;
    video: string;
    text: string;
    hashtags?: Object[];
    date?: string;

用户现在可以执行以下操作:

  1. 喜欢这个想法
  2. 分享想法
  3. 添加评论
  4. 添加建议
  5. 群体可以支持一个想法

用户和应用程序还将定期执行以下操作:

  1. 用户搜索iDAYANS(searchComponent)
  2. 用户搜索IDEAHASHTAGS(searchComponent)
  3. 用户在时间跨度(搜索COMPONENT)
  4. 中搜索所有想法
  5. 应用程序要求某个事件的所有想法(EventComponent)
  6. 应用要求某个人的所有想法(ProfileComponent)
  7. 应用要求某个群体的所有想法(groupComponent)
  8. 应用要求大多数喜欢的想法
  9. 应用要求与最支持的群体提出想法

要完全渲染创意视图,我必须检索有关:

的不同信息
  1. 作者
  2. 评论
  3. 提案
  4. 事件
  5. 喜欢

  6. 支持组

在我看来,我想创建6个集合:

  1. 想法收集
  2. 用户集合
  3. 评论集合
  4. 提案收集
  5. 活动集合
  6. 集团集合

...进行以下查询以呈现IdeaComponent的视图

 // the idea has an author
    // query idea collection to retrieve
    userID: string;
    userName: string;
    userImage: string;
    // user can add comments
    // query comment collection to retrieve
    commentID: string;
    commentText: string;
    commentAuthorName: string; // userName
    commentAuthorID: string; // userID
    commentAuthorImage: string; // userImage
    // user can add proposals how to change the idea
    // query proposal collection to retrieve
    proposalID: string;
    proposalText: string;
    proposalAuthorName: string; // userName
    proposalAuthorID: string; // userID
    proposalAuthorImage: string; // userImage
    // user discuss the idea at real life events
    // query event collection to retrieve
    eventID: string;
    eventAuthorName: string;
    eventAuthorID: string;
    eventAuthorImage: string;
    // user can like the idea
    // query user collection to retrieve
    userID: string;
    userName: string;
    userImage: string;
    // groups can support the idea
    // query groups collection to retrieve
    groupID: string;
    groupName: string;
    groupImage: string;

有两种模拟数据的方法:

直接来自Firestore

检查文档:https://firebase.google.com/docs/firestore/data-model

2来自您的代码

即:我删除了IDEAID,因为它将自动生成。

export interface IdeaModel {
    location: string;
    image: string;
    video: string;
    text: string;
    hashtags?: Array<string>;
    date?: Date;
}

最新更新