Search code examples
javascriptparse-platformionic2parse-server

parse server add current user to relation in users class (javascript SDK)


i want to do something like who visit your profile function in my ionic application, simply this function take the current user parse object and insert it in a relation column present in users class called who visited

so what i would like to do first is to query the relation to see if the current user already there and if not insert it in the relation

tried the following code:

var currentUser = Parse.User.current(); //current user object
var user = this.navParams.get('user'); // parse user object passed through navparams
var relation = user.relation("whoVisited");
relation.add(currentUser)
user.save()

but it gives me POST error 400 Bad Request


Solution

  • After searching for 6 hours i found the following

    User class is protected and no user can modify other user data thats why i was getting the error

    I managed to do the same function using cloud code and the power of master key