0
votes

Im having a slight problem with reading user data from my database. I have already loaded the user in via the function and i can push to the database without any problems.

 var ref = new Firebase("https://FBURL.firebaseio.com/");
    var userRef = ref.child('posts');
 $scope.addMessage = function(){
        var yyyy = date.getFullYear().toString();
        var trimyyyy = yyyy.substr(2);
        var mm = (date.getMonth()+1).toString();
        var dd = date.getDate().toString();
        var yyMMdd = trimyyyy + mm + dd;

        userRef.child(user.uid).push({
            date: yyMMdd,
            post: $scope.newMessage
        })
    }

Writing to database will put content in: DB_name -> posts -> user.uid -> child -> date: & post:

However now that i want to read the content in the users uid node i get nothing.

$scope.messages = fbutil.syncArray(user.uid, {limit: 10});

Then i simply repeat it.

<ul id="messages" ng-show="messages.length">
    <li ng-repeat="message in messages | reverse">{{message.text}}</li>
</ul>

Im also getting a "{"code":"PERMISSION_DENIED"}" from an error output that i have but i think its a code problem rather than a problem with the security rules.

1

1 Answers

1
votes

If you want to get the posts from the user you need to use:

$scope.messages = fbutil.syncArray('posts/'+user.uid);

Because you stored it below posts.