0

I am trying to build an activity feed that gets all recent activities from people you follow and your own activities you created. I want to do this in the cloud so as to have a consistent dataset across all platforms.

The way my classes are set up, in the "activity" class, there is a pointer to the user class. In my "follow" class, there are two columns, "To" and "from". Each of these are also pointing at the user class.

I'll appreciate example codes on how to do this.

Edit:

Parse.Cloud.define("test", function(request,response){
    var username = request.params.username;

    // First query to get the current user
    var query = new Parse.Query(Parse.User);
    query.equalTo("username", username);

    //Second query to get his friends
    var query2 = new Parse.Query(Parse.User);
    query2.containedIn("username", ["mhp_samuel","singletune","jabbs"]);

    var mainQuery = Parse.Query.or(query, query2);
    mainQuery.find({
        success:function(results){

            //This is where I want to query the activity class. I'm just doing response.success to ensure the results are returned.
            response.success(results);

        },
        error:function(){
            response.error();
        }
    });

});

This is what I did to get it working.

Parse.Cloud.define("test", function(request,response){
    var username = request.params.username;
    var query = new Parse.Query(Parse.User);
    query.equalTo("username", username);
    var query2 = new Parse.Query(Parse.User);
    query2.containedIn("username", ["mhp_samuel","singletune","jabbs"]);

    var mainQuery = Parse.Query.or(query, query2);
    mainQuery.find().then(function(results){
        var qq = new Parse.Query("Tunes");
        qq.containedIn("parent", results);
        return qq.find();
    }).then(function(result){
        response.success(result);
    }, function(error){
        response.error(error);
    });

});
Mr Smith
  • 331
  • 1
  • 4
  • 14

0 Answers0