3

I get the list of keys from my iterative forEach function from database users:

var projectsquery = DatabaseRef.ref('/users/' + userId).orderByKey().once("value")
    .then(function onSuccess(snapshot) {
        snapshot.child("projects").forEach(function(childSnapshot) {
            var userprojects = childSnapshot.val();
            console.log("my list :", userprojects );
        });
    });

the console log is showing the values for the projects child under user database for the current signed in user. This is fine.
Here is the example console output:

my list : -KUTLAZENGlxtzCtEfaZ
my list : -KUTLM8r_kmVSTaxzLW5
my list : -KUTPrs6ARZXjbjtNr7O

I am trying to pass these keys into the equalTo of the following:

var projectquery = DatabaseRef.ref("projects").orderByKey().equalTo("-KUTPrs6ARZXjbjtNr7O");
$scope.projectslist = $firebaseArray(projectquery);

which is trying to fetch the projects from projects database based on the key which is passed into equalTo. However, this is an example of one key manually set. How can I pass an array of multiple keys? In other words, how I can I filter my projects based on the project keys which are stored in another database (users) as a value under a child of this database?

cplus
  • 1,115
  • 4
  • 22
  • 55
  • Firebase does not support a `WHERE id IN (1,2,3)` operation (see [this answer](http://stackoverflow.com/questions/29560088/firebase-equivalent-to-sql-where-in)). Nor does it have any need to, because the speed advantage over looking them up is minimal. To learn why, see my answer here http://stackoverflow.com/questions/35931526/speed-up-fetching-posts-for-my-social-network-app-by-using-query-instead-of-obse/35932786#35932786 – Frank van Puffelen Oct 22 '16 at 15:03
  • To learn more about joining data with AngularFire, see http://stackoverflow.com/questions/30299972/joining-data-between-paths-based-on-id-using-angularfire – Frank van Puffelen Oct 22 '16 at 15:04

0 Answers0