dimanche 3 juillet 2016

FIRDatabaseQuery: how to do an inner join


I'm trying to do an inner join on a FIRDatabaseQuery object.

below is the database structure. I have some posts that are linked to post-comments. I am trying to get all the posts that a specific user added a comment on:

 {
   "posts" : {
    "-KIycKhZU55dmKnHbbxv" : {
      "author" : "John Doe",
      "body" : "This is a post test",
      "title" : "test",
      "uid" : "SHaH36BLwgPvwgi9cDmRnsnONFB2"
    },
    "-KIyg_ks1O5QL4_4dfq_" : {
      "author" : "Jane Doe",
      "body" : "This is a post test",
      "title" : "test2",
      "uid" : "x5leSBGArnd10JilD9YDyNBNfZ03"
    },...
   }
  "post-comments" : {
    "-KIycKhZU55dmKnHbbxv" : {
      "-KIycMyL0Vy1BHVdI4zc" : {
        "author" : "toto",
        "text" : "test",
        "uid" : "SHaH36BLwgPvwgi9cDmRnsnONFB2"
      },
      "-KIyg_ks1O5QL4_4dfq_" : {
        "author" : "toto",
        "text" : "test",
        "uid" : "SHaH36BLwgPvwgi9cDmRnsnONFB2"
      }
    },...
 }

in SQL this will be translated into a inner join query similar to:

Select * from post inner join post-comments on post-id where post-comments.uid = "user id"

Does anybody know how o get something similar to an inner join in firebase?

Thanks a lot, Yacine


Aucun commentaire:

Enregistrer un commentaire