Query on multiple values in Firebase, similar to IN() SQL functionality

后端 未结 2 1077
南旧
南旧 2020-12-10 22:02

I have an array that looks like this:

validZipCodes = [
  \"84606\",
  \"84605\",
  \"84601\"
]

I\'m querying some data like this:

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-10 22:52

    Here is how I eventually did it:

    With the foreach command you can easily manipulate data and then push it into an array to re-create a collection of data however you need it.

    $scope.validZipCodes = [];
    $scope.validContractorJobs = [];
    
    var Jobs = firebase.child('Jobs');
    
    contractorJobs.on('value', function(snap) {
                snap.forEach(function(job) {
                    angular.forEach($scope.validZipCodes, function(value, key) {
                        if(job.val().ZipCode == value) {
                            $scope.validContractorJobs.push(job.val());
                        }
                    });
                });
            });
    

提交回复
热议问题