title: Firebase realtime database querying on a field
body: <p>I have a firebase database with the following structure of employee data. I have a user table as well which has a 'companyId' property. Each time a user logs in I want to fetch all the employees which match the users 'companyId'. Is it possible to implement this using firebase database rules or I have to write some query.</p>
  
  <pre><code>Employee: 
  {
    "+911234567890" : {
      "admin" : true,
      "companyId" : "C1",
      "depId" : "D5",
      "designation" : "D1",
      "dob" : "2019-04-02T18:30:00.000Z",
      "doj" : "2019-04-18T18:30:00.000Z",
      "empEmail" : "nishant.k@zetwerk.com",
      "empId" : "E4",
      "empPhone" : "+911234567890",
      "first_name" : "Nishanth",
      "gender" : "male",
      "last_name" : "K",
      "manager" : "M2",
      "type" : "permanent"
    },
    "+919035105184" : {
      "admin" : true,
      "companyId" : "C2",
      "depId" : "D1",
      "designation" : "Software engineer",
      "dob" : "1991-07-31T18:30:00.000Z",
      "doj" : "2018-07-24T18:30:00.000Z",
      "empEmail" : "arpit.s@zetwerk.com",
      "empId" : "E10",
      "empPhone" : "+919035105184",
      "first_name" : "Arpit",
      "gender" : "male",
      "last_name" : "Srivastava",
      "manager" : "M1",
      "type" : "PERMANANENT"
    },
    "+919698286236" : {
      "admin" : false,
      "companyId" : "C1",
      "companyName" : "Zetwerk",
      "depId" : "D1",
      "depName" : "Engineering",
      "empEmail" : "dhanalakshmi.s@zetwerk.com",
      "empId" : "E1",
      "empPhone" : "+919698286236",
      "firebaseId" : "-LbNvaKFjqaaMl_JbNxd",
      "first_name" : "Dhanalakshmi",
      "type" : "contract"
    },
    "+919738749877" : {
      "companyId" : "C1",
      "depId" : "D2",
      "empEmail" : "sagar.k@zetwerk.com",
      "empId" : "E3",
      "empPhone" : "+919738749877",
      "firebaseId" : "-LbNbABScOEzl-sMFE1u",
      "first_name" : "Sagar",
      "type" : "permanent"
    },
    "+919972984851" : {
      "admin" : true,
      "companyId" : "C1",
      "depId" : "D6",
      "designation" : "SDE",
      "dob" : "2019-04-23T18:30:00.000Z",
      "doj" : "2019-04-02T18:30:00.000Z",
      "empEmail" : "saikumarganji1994@gmail.com",
      "empId" : "Z002",
      "empPhone" : "+919972984851",
      "first_name" : "Sai",
      "gender" : "male",
      "last_name" : "Kumar",
      "type" : "permanent"
    }
  }
  
  
  User:
   "1":{
    "Name" : "Nishant Gupta",
    "companyId" : "C1",
    "role" : "admin"
  } 
  
  </code></pre>