Closed mmaelicke closed 2 years ago
api.find_entry
already accepts the parameter details
since v0.2.2
.
Entries are found by passing name=value
pairs as a dictionary. The name=value
pairs must exactly match the key
and the value in raw_value
(jsonb) stored in metacatalog.
Can we close this issue or did you want to implement other functionalities @mmaelicke?
@AlexDo1 please provide a unittest to make sure that the current implementation can:
Two of these tests already exist:
- find details by key and value: https://github.com/VForWaTer/metacatalog/blob/1ff57d379f49a45dd1aef07c3553b12e4514fc71/metacatalog/test/test_api_add_find.py#L274-L275
- find both nested (to one level): https://github.com/VForWaTer/metacatalog/blob/1ff57d379f49a45dd1aef07c3553b12e4514fc71/metacatalog/test/test_api_add_find.py#L277-L279
When searching for details, details must be a dictionary exactly representing the detail associated to an entry: https://github.com/VForWaTer/metacatalog/blob/9a046f38191153b8326d79b99d76eacb1816b17b/metacatalog/api/find.py#L1029-L1031
So it is currently not possible to (1.) find details by key and (4.) find details by value.
@mmaelicke do you want me to implement the functionality to find entries via details based only on the key or value?
Great. Yes, I think at least the key-only part should be implemented. The best solution would be to implement like this:
key and value:
api.find(details=dict(mykey='myvalue')) # isinstance(dict)
api.find(details=dict(mykey='%value')) # isinstance(dict) and '%' in value
key only:
api.find(details='mykey') # isinstance(str)
api.find(details=['mykey', 'mykey2']) # isinstance(list)
value only:
api.find(details={'*': 'myvalue'}) # isinstance(dict) and key=='*'
Let me know if this is not as straightfoward as expected. But SQLAlchemy should have the functionality implemented.
We need some ideas, how the details can be utilized to find
Entry
records by ID. Either add as parameter toapi.find_entry
or put into a new api endpoint.