Parse & JS: Retrieving comment using the parentId

This entry is part 23 of 25 in the series Parse & Javascript

From the parent, we could retrieve the objectId.

Since we have this objectId in each comment object, we can retrieve the relevant comment of the Post.

<!doctype html>
<head>
        <title>My Parse App</title>
        
    <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
        
    <script type='text/javascript' src='http://www.parsecdn.com/js/parse-1.2.17.min.js'></script>
</head>
 
<body>
 
<div>
        
    <div style='display:none' class='error'>
                <h1>Movie not found</h1>          
    </div>
            
    <div style='display:none' class='success'>
                <h1>Movie Found</h1>            
    </div>
</div>
 
<script>
    Parse.initialize('kYqz3wRHRa0GDX7viRIVXKDVNIaI0q7Fw6Ms3pv2', 'yPjRYQmwZC2MthUPrer1mU9dDpr84xVQjmEtT7fS');
    var Comment = Parse.Object.extend('Comment');
    var comment = new Comment();

    var query = new Parse.Query(Comment);

    query.equalTo('parentId', 'NBQjz5Rr2y');

    query.find(
            {
                success: function (comment) {
                    $('.success').show();
                    var content = comment[0].get('content');
                    alert(content);
                }
            }
    );

</script>
 
</body>
</html>
Try The Code
Series Navigation<< Parse & JS: Relational data
Parse & JS: Return only one object >>

Leave a comment

Leave a Reply