The Parse android SDK does not allow updating of a column in the user table
while I am using getCurrentUser()
method to mark it as authenticated. When I call saveInBackground()
on it I get the following error in the log file:
Uncaught internal server error. { [MongoError: exception: Mod on _id not allowed] name: 'MongoError'
Below is the code I am using for saving:
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.