opengeospatial / sensorthings

The official web site of the OGC SensorThings API standard specification.
134 stars 29 forks source link

Removing items from a many-many relation #19

Open hylkevds opened 7 years ago

hylkevds commented 7 years ago

Most relations in the SensorThings API are one-to-many. In those cases you can remove a relation on the "many" side by changing it on the "one" side. For example, you can remove a Datastream from the list Things(x)/Datastreams by changing the Datastream(x)/Thing of the Datastream you want to remove from Things(x)/Datastreams.

However, there are 2 many-many relations:

It seems to be impossible to remove an item from such a relation, it is only possible to add to such a relation.

Should this be addressed? What do you all think?

hylkevds commented 5 years ago

It might be possible to actually do this by using the already optional JSON PATCH format [RFC6902]. To change the first ObservedProperty of MultiDatastream X, something like this might work:

PATCH MultiDatastreams(x)
Content-Type: application/json-patch+json

[
  { "op": "replace", "path": "/ObservedProperties/0", "value": {"@iot.id": y } }
]

I'll try it out and report back.

hylkevds commented 11 months ago

The OData 4.01 way is described here:

OData Version 4.01. Part 1: Protocol - 11.4.6.2 Remove a Reference to an Entity A successful DELETE request to the URL that represents a reference to a related entity removes the relationship to that entity.

What a "URL that represents a reference" exactly is is described in OData Version 4.01. Part 2: URL Conventions - 4.4 Addressing References between Entities

Example 29: three ways of unrelating Categories(1) and Products(0); the second option is supported only in OData 4.01

DELETE http://host/service/Categories(1)/Products/$ref?$id=../../Products(0)
DELETE http://host/service/Categories(1)/Products(0)/$ref
DELETE http://host/service/Products(0)/Category/$ref