2

I am triying to delete a field of an object in Back4App, but I cannot achieve such a simple operation. By "deleting" I mean set a field that has data to "undefined". According to the guide, I just have to call myObject.remove("field"). I tryed that (with correct field name), then save the object (I tried all of the saving functions available), but the object is unmodified. There is no error thrown.

I can change the field (with put ("field", otherObject), because it is a pointer field) with no problem. But put("field", JSONObject.NULL) is not working either.

I do not know if this code would work in the original Parse, I am coding this now. The equivalent function in iOS ([myObject removeObjectForKey:@"field"];) in the same database is working nicely...

ElYeante
  • 1,745
  • 21
  • 22

1 Answers1

1

For what I could gather from your question, the problem is that you're trying to clean a field from a relational object:

"I can change the field (with put ("field", otherObject), because it is a pointer field)"

On that case, I'm not really sure if using simple object deletion would work. I'd suggest you to take a look at Parse's documentation on Relational Data in order to understand how you should remove that field.

Long story short, I'm not sure if the idea of cleaning the field that you wish will work, but what can be done when you have a relation like this:

ParseUser user = ParseUser.getCurrentUser();
ParseRelation<ParseObject> relation = user.getRelation("field");
relation.add(MyObject);
user.saveInBackground();

Is to simply remove the relation like this:

relation.remove(MyObject);

As you can check in the link above.

Casagrande
  • 90
  • 7