Skip to content

Save Array using cloud code and parse server #4365

Closed
@FarisAlbalawi

Description

@FarisAlbalawi

I'm trying to Save array using cloud cod with parse server. I want if user1 follow user2 I want the user2 get the user1's objectId and Save it to Array table in user class

class called (_User) in user class table called (whoFollowers)

this is my cloud code

Parse.Cloud.define("whoFollowers", function(request, response) {
var newts = new Array();
var parsedJson = JSON.parse( request.params.push );
for ( var i = 0; i < parsedJson.length; i++ )
{

var userId = request.params.userId;
var User = Parse.Object.extend('_User'),
var whoFollowers = request.params.datalist[i];
User.set("push", "0");
newts[i]=User;
}

Parse.Object.saveAll(newts,{
success: function(list) {
response.success("ok " );

},
 error: function(error) {
response.error("failure on saving list ");
},
});    
});

// swift code

 let request = [
                "userId" : self.otheruserObj.objectId!,
                "whoFollowers" : currUser.objectId!,
                ] as [String : Any]

            PFCloud.callFunction(inBackground: "whoFollowers", withParameters: request as [String : Any], block: { (results, error) in
                if error == nil {
                    print ("success")

                }})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions