Skip to content
This repository was archived by the owner on Jan 12, 2019. It is now read-only.
This repository was archived by the owner on Jan 12, 2019. It is now read-only.

$remove on a NormalizedCollection throws an Exception #90

Description

@apptimise

I have a service with the following function:

 this.getRequested = function (uid) {
        var ref = new Firebase(FBURL);
        var refSearch = ref.child('profiles/' + uid + '/friends/requested');
        ///*
        var refSearch = new Firebase.util.NormalizedCollection(
            [ref.child('profiles/' + uid + '/friends/requested'), "frId"],
            [ref.child('users'), 'users', 'frId.username']
        ).select('frId.username', 'frId.status', 'users.img', 'users.uid').ref();
        //*/
        return $firebaseArray(refSearch);
}

After binding this to a $scope variable:
$scope.frRequested = Friends.getRequested(authData.uid);

Now if I remove a record as follows:
$scope.frRequested.$remove(friend);

I get the following WARNING:

FIREBASE WARNING: Exception was thrown by user callback. TypeError: Cannot read property 'ref' of null
    at Object.i.update (https://cdn.firebase.com/libs/firebase-util/0.2.5/firebase-util.min.js:9:22050)
    at https://cdn.firebase.com/libs/firebase-util/0.2.5/firebase-util.min.js:9:18061
    at https://cdn.firebase.com/js/client/2.4.2/firebase.js:203:710
    at gc (https://cdn.firebase.com/js/client/2.4.2/firebase.js:52:165)
    at cc (https://cdn.firebase.com/js/client/2.4.2/firebase.js:30:216)
    at dc (https://cdn.firebase.com/js/client/2.4.2/firebase.js:29:1259)
    at Ji.h.Ob (https://cdn.firebase.com/js/client/2.4.2/firebase.js:223:440)
    at X.set (https://cdn.firebase.com/js/client/2.4.2/firebase.js:259:335)
    at X.remove (https://cdn.firebase.com/js/client/2.4.2/firebase.js:262:146)
    at https://cdn.firebase.com/libs/firebase-util/0.2.5/firebase-util.min.js:9:19948 
firebase.js:52 Uncaught TypeError: Cannot read property 'ref' of null

I have tried a similar situation without using the NormalizedCollection, and everything works fine, i.e. when the service is as follow, it works without a problem:

 this.getRequested = function (uid) {
        var ref = new Firebase(FBURL);
        var refSearch = ref.child('profiles/' + uid + '/friends/requested');
        return $firebaseArray(refSearch);
 }

Is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions