Parse android sdk does not allow to update a column in the user table
While I am using getCurrentUser() method to mark it as authenticated but when I call save on it. it gives me the error in the log file that
Uncaught internal server error. { [MongoError: exception: Mod on _id not allowed]
name: 'MongoError'
byte[] data = "Working at Parse is great!".getBytes();
final ParseFile file = new ParseFile("abcdef.txt", data);
ParseUser currentUser = ParseUser.getCurrentUser();
if (currentUser != null) {
// do stuff with the user
currentUser.put("column_name", file);
currentUser.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Log.i("KQ", "update successfully");
} else {
Log.i("KQ", "update error e = " + e);
}
}
});
} else {
// show the signup or login screen
Log.i("KQ", "else");
}
Till I get a good answer.I am currently using my cloud code beforeSave trigger in parse to remove the id field to get rid of the exception and unblock my work. any good answer will still be appreciated.
code I am using right now is as follows in the cloud code.
Parse.Cloud.beforeSave(Parse.User, function(request, response) {
// For Android SDK remove id field while updating a user becasue it was creating MongoDB Exception in android.
if (request.object.get("updatedFrom") == 'android') {
request.object.unset("updatedFrom");
request.object.unset("id");
}
response.success();
});
thanks.