related child deletion with REST

Hi,

I am working with a web application using your REST sdk.
The problem I have is the following:

I have a table TABLE_1, which has a relation with a table TABLE_2

If I create an instance of TABLE_1, fill a property of array type with an array of objects of type TABLE_2, and I save TABLE_1, I can see the objects of both TABLE_1 and TABLE_2.

Now I want to update the TABLE_1 object, and I send a PUT request passing as body the same TABLE_1 object, but with a new array of TABLE_2 objects.
I leave the field __meta untouched:

EXAMPLE


{
	"code": "1",
	"description": "description",
	"created": 1494678322000,
	"ownerId": null,
	"__meta": "{"
	relationRemovalIds ":{},"
	selectedProperties ":["
	code ","
	description ","
	created ","
	ownerId ","
	updated ","
	objectId "],"
	relatedObjects ":{"
	TABLE_2 ":["
	1 C1C4A67 - B4B6 - B5D5 - FFC4 - 419 C82C98D00 ","
	4 C37F1C2 - E573 - B515 - FFC6 - E9AD60D45800]
}
",
"items": [{
		"___class": "TABLE_2",
		"name": "test"
	},
	{
		"___class": "TABLE_2",
		"name": "test1"
	}
],
"___class": "TABLE_1",
"updated": 1497633352000,
"objectId": "BA90E116-1EA1-39AC-FF82-252018F0B300"
}

1 C1C4A67 - B4B6 - B5D5 - FFC4 - 419 C82C98D00 and 4 C37F1C2 - E573 - B515 - FFC6 - E9AD60D45800 are the ids of previous 2 objects, and in the array there 2 brand new objects.
I left untached __metadata from the previous get operation.

WHAT I EXPECT
TABLE_1 has 2 related objects => OK
TABLE_2 has only 2 objects, the new ones => WRONG , I have 4 objects in TABLE_2, the old 2 and new 2.

I can I update an object, deleting the child objects not referenced anymore?

Thank you

This works as designed. When you send an update with new related objects, the existing ones are not deleted.

Regards,
Mark

Is there a way to delete old relations?

You can delete the old relations using the “bulk delete” operation. You should do it before you update the parent object.