Possible to add and remove list items at the same time in the edit api
Right now, in the metadata edit api for list quantities (like coauthors, references, datasets, etc) you can specify the request json using one of the following formats:
"qty": <single value or list>
-
"qty": {"op": <op>, "values": <single value or list>}
, whereop
is one of the strings "add" | "remove" | "set"
(if <single value or list>
is a single value, v
, we treat it as the list [v]
)
Datasets are treated differently from the other quantities, however:
for all list quantities except datasets Method 1) and method 2) with op = set are set-operations, i.e. they sets qty to the provided list.
for datasets set-operations are not permitted. Instead, method 1) is interpreted as add-operations, and for method 2), it is not permissible to specify op = set.
The reason for the difference is that you are only supposed to be able to edit datasets that you own (and that don't have a DOI), but it is of course a bit confusing. Another limitation with this is that you can only do either an add or a remove operation, not both, in the same api call, which is limiting and causes problems for the implementation of the edit ui.
Possible improvements:
- Allow set-operations for datasets. Should be possible, we just need to check that the operation is valid
- If we allow set-operations for datasets, we could also interpret both methods consistently.
- Perhaps we could also modify method 2) so that we can specify both add and remove, rather than just one of them, for example like this:
"qty": {"add": <single value or list>, "remove": <single value or list>, "set": <single value or list>}
(allowing the user to specify either a) set b) add c) remove, or d) add+remove in one operation).