Should I use type or type-id?


For a user script, I need to browse the JSON response of various /ws/2/ web services (API?).

I want to see if there is this or that relationship type on my entity.
For example, if I want to see if my release group includes other release groups, I can do either of these:

  • relation[r].type == "included in" && relation[r].direction == "backward"
  • relation[r]["type-id"] == "589447ea-be2c-46cc-b9e9-469e1d06e18a" && relation[r].direction == "backward"

The first one with type, is more elegant and convenient.

But why does the second one with type-id exist?
Does it mean that we should always use type-id because type could be renamed in the future?

Relationship Type: included in / 589447ea-be2c-46cc-b9e9-469e1d06e18a

For the moment, in order to not forget the 2 possibilities, I have used both:

	releases[r]["release-group"].relations[rgRel].type == "included in"
	|| releases[r]["release-group"].relations[rgRel]["type-id"] == "589447ea-be2c-46cc-b9e9-469e1d06e18a"
&& releases[r]["release-group"].relations[rgRel].direction == "backward"