WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Data Structure

Scott Bergler edited this page Apr 15, 2020 · 5 revisions

This wiki is about trying to decide on what our data shapes should be and to think about how to enact them in Firebase.

Sara and I, based on Steve's comments on it, see these two possibilities:

This is a collection of items. Each item has a field that is the token of the user who saved it to their list.

[
  {
    "name": "blah",
    "next_purchase": "soon",
    "last_purchase": "some date string/object",
    "user_token": "ahsdfihwaefwe"
  },
  {
    "name": "blah",
    "next_purchase": "soon",
    "last_purchase": "some date string/object",
    "user_token": "ahsdfihwaefwe"
  },
  {
    "name": "blah",
    "next_purchase": "soon",
    "last_purchase": "some date string/object",
    "user_token": "ahsdfihwaefwe"
  },
  {
    "name": "blah",
    "next_purchase": "soon",
    "last_purchase": "some date string/object",
    "user_token": "ahsdfihwaefwe"
  }
]

This is a collection of users, each with a collection of items.

[
  "user_token": [
    {
      "name": "blah",
      "next_purchase": 7,
      "last_purchase": "some date string/object"
    },
    {
      "name": "blah",
      "next_purchase": 30,
      "last_purchase": "some date string/object"
    },
    {
      "name": "blah",
      "next_purchase": 14,
      "last_purchase": "some date string/object"
    },
    {
      "name": "blah",
      "next_purchase": 7,
      "last_purchase": "some date string/object"
    }
  ],
  "user_token": [
    {
      "name": "blah",
      "next_purchase": 7,
      "last_purchase": "some date string/object"
    },
    {
      "name": "blah",
      "next_purchase": 30,
      "last_purchase": "some date string/object"
    },
    {
      "name": "blah",
      "next_purchase": 14,
      "last_purchase": "some date string/object"
    },
    {
      "name": "blah",
      "next_purchase": 7,
      "last_purchase": "some date string/object"
    }
  ]
]

This is a collection of Users. Each User has a token field and a sub-collection, shopping_list, which is a collection of items.

{
  "users": [
    {
      "user": "ahsdfihwaefwe",
      "shopping_list": []
    },
    {
      "user": "ahsdfihwaefwe",
      "shopping_list": [
        {
          "name": "blah",
          "next_purchase": "soon",
          "last_purchase": "some date string/object"
        },
        {
          "name": "blah",
          "next_purchase": "soon",
          "last_purchase": "some date string/object"
        },
        {
          "name": "blah",
          "next_purchase": "soon",
          "last_purchase": "some date string/object"
        },
        {
          "name": "blah",
          "next_purchase": "soon",
          "last_purchase": "some date string/object"
        }
      ]
    }
  ]
}

Some relevant links: Firebase data model

Clone this wiki locally