Using AngularFire, is it possible to to create relational-style databases? Or access the UniqueIDs?

前端 未结 2 1269
梦谈多话
梦谈多话 2021-02-10 14:03

I saw this post on Firebase\'s blog explaining the best way to create relational data objects using their platform. I\'m struggling to translate these concepts to AngularFire,

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-10 14:34

    Yes you can access the ID! Use the code below!

    var chru;
    var ref = new Firebase("https://myapp.firebaseio.com/users/");
    var sync = $firebase(ref);
    var users= syncSelect.$asArray();
    $scope.users= users;
    users.$loaded().then(function() {
        chru = users.length;
    });
    
    $scope.specificIdOnSelect = function() {
        var jj;
        for (jj = 0; jj < chru; jj++) {
            var keyer = users.$keyAt(jj);
            var rec = users.$getRecord(keyer);
    
            if ($scope.userSelected== rec.name) {
                alert("Unique Key of " + $scope.users+ " is " + users.$keyAt(jj));
            }
        }
    };
    
    $scope.allIds = function() {
        var jj;
        for (jj = 0; jj < chru; jj++) {
            var keyer = users.$keyAt(jj);
            var rec = users.$getRecord(keyer);
            alert("Unique Key of " + $scope.users+ " is " + users.$keyAt(jj));
        }
    };
    

提交回复
热议问题