kindly me in updating user document nested field. have user document having visiblebytheuser field having avatarurl, name, email fields. want update avatarurl field when profile pic uploaded. when try update overriding complete object. reference find service code below.
var headers = { 'authorization': 'basic qwxhzgrpbjpvcgvuihnlc2ftzq==', 'contenttype' : 'application/json', 'x-baasbox-appcode' : baasboxappcode, 'x-bb-session' : window.localstorage.getitem("usertoken") }; //todo: change updation format. //below format overriding complete object. var data = { "visiblebytheuser": { "avatarurl" : updatedavatarurl }, }; url = serverurl+ '/me'; var promise = $http({ method: "put", url : url, headers : headers, data: data }); promise.then(function(data){ console.log("success data in profileupdation is:"+ json.stringify(data)); }); promise.error(function(error) { console.log("error in profileupdation is:",json.stringify(error)); }); return promise;
i figured out answer. rather updating specific field of nested objects not possible in baasbox it's better update whole field having nested objects in it.
here code i'm using this
avatrurlupdation : function(visiblebytheuserforupdation){ /*console.log("entered avatarurlupdation");*/ var headers = { 'authorization': 'basic qwxhzgrpbjpvcgvuihnlc2ftzq==', 'contenttype' : 'application/json', 'x-baasbox-appcode' : baasboxappcode, 'x-bb-session' : window.localstorage.getitem("usertoken") }; //todo: change updation format. //below format overriding complete object. var data = { "visiblebytheuser" : visiblebytheuserforupdation }; url = serverurl+ '/me'; var promise = $http({ method: "put", url : url, headers : headers, data: data }); promise.then(function(data){ console.log(data); }); promise.error(function(error) { console.log("error in profileupdation is:",json.stringify(error)); }); return promise; }
Comments
Post a Comment