copy - Automatic copying of some value whenever it's changed in cloud code [ parse.com ] -


how write in cloud code ( parse.com ) short program automaticaly copies value of field of 1 pfobject field of other pfobject (of different class original one) whenever original field being changed? example have user's name , want automatically copied posts' objects whenever changes name. , done on servers' side. need written in cloud code.

to implement functionality, can use parse cloud aftersave procedure. assume have profile table in parse , user has option s/he can update name. can write cloud aftersave function search post table (based on userid) , update name fields (this simple scenario) below code example;

parse.cloud.aftersave("profile", function(request) {    var updatedlist = [];   var query = new parse.query("post");   query.equalto("userid", request.object.get("userid"));   query.find({     success: function(records)      {         for(var = 0;i < records.length;i++)         {             var currentobject = records[i];             currentobject.set("name",request.object.get("name"));             updatedlist.push(currentobject);         }         parse.object.saveall(updatedlist,{         success: function(list) {},         error: function(error) {},       });     },     error: function(error)      {     }   }); }); 

the above code triggered after save in profile table. searches post class , finds entries related current user (requester). following updates post table changes name field.

also not forget procedure triggered updates in profile table. option write cloud function trigger when update in profile (on application). hope helps.

regards.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -