title: How to share data between users in Firebase?
body: <p>In a database like this:</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>{
    "users": {
      "simplelogin:213": {    
        "provider": "password",
        "name": "bobtony",
        "friends": {
          "Andrew Lee": true,
          "James Tamplin": true
        }   
      },
      "twitter:123": {
        "provider": "twitter",
        "name": "Andrew Lee",
        "friends": {}
      },  
      "facebook:456": {
        "provider": "facebook",
        "name": "James Tamplin",
        "friends": {}
      }   
    },  
    "messages": {  
      "simplelogin:213": {    
         "-JkpwAnieKjQVsdtPD4m" : {
            "content" : "Hello World"
        }
      }  
    }  
  }
  </code></pre>
  
  
  
  <p>Considering that bobtony add Andrew Lee as his friend, how Andrew Lee can read bobtony messages? A similar question asked <a href="https://stackoverflow.com/questions/17798444/how-to-structure-firebase-data-and-rules-for-sharing-data-between-users">here</a>, but without good solution. I know I can have a rule to allow reading the message, but the "friend" users just does not to know the path to read them.</p>
  
  <p>Update: After spend some time thinking, i got:</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>{
    "users": {
      "user1": {  
        "name": "bobtony",
        "partners": {
          "user2": {
              "accepted": true
          }
        },
        "customers":{
          "customer1": true,
          "customer2": true
          // hundreds of clients
        },
        "orders":{
          "order1": true,
          "order2": true
          // hundreds of orders
        }     
      }
    },  
    "customers": {  
      "customer1": {  
         "name" : "james"
        }
      }
  }
  </code></pre>
  
  
  
  <p>So, would be ok to have something like this? This way I can traverse my own customers and my partners customers.</p>