Firebase Rules Flat structure for stores, user, products relationship

260 views Asked by At

i try to build a firebase Datastructure. i come from a SQL world and have Problems understanding noSQL Datastructur.

i would like to have a Datastructure for Stores. Each Store has some Datafields like Storename, Address and so on. A Store should also have a Users Object storing all the Users that work in this Store and are able to add new Products and modify them. There is also a Dataobject that stores the Products and the Products should have also a relation to the users(stores). Can someone give me a hint how to build this as flat as possible?

My data structure right now:

  "rules": {
    "users": {
      "$uid": {
       ".write": "auth !== null && auth.uid === $uid",
       ".read": "auth !== null && auth.provider === 'password'"
      }
     },
    "products": {
      "$uid": {
        ".write": "auth !== null && auth.uid === $uid",
        ".read": true
       }
     },
    "stores": {
      "$uid": {
        ".write": "auth !== null && auth.uid === $uid",
        ".read": true
      }
    }
   }

Thanks

0

There are 0 answers