Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query for "/meta" #971

Open
mrsimpson opened this issue Mar 30, 2022 · 3 comments
Open

Query for "/meta" #971

mrsimpson opened this issue Mar 30, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@mrsimpson
Copy link

mrsimpson commented Mar 30, 2022

Motivation

We want to use the /meta resource to add non-mds-standard-information to entities, majorly geographies and policies.
E. g. we want to "tag" policies with a type, meaning the policy regulates a fleet.
However, we cannot query for this information easily, but we need to retrieve the full data set and filter afterwards.

Proposal

Add a query parameter to the APIs for reading entities (mds-policy, mds-geography-api) which joins and filters based on metadata. Since meta holds a JSON, this will have to translate to a fancy query on the particular services.
Imho, it's fine to query only for equality (no pattern-patching or other operators).

/policies?meta.type=fleet should be sufficient. Of course, supporting the additional jsonb operators is an option as well, but I don't know if this is consumer friendly ;)

@mrsimpson
Copy link
Author

@avatarneil as discussed today: here's the issue. I have not found queries for meta anywhere at a first glance

@avatarneil
Copy link

Thanks for raising this issue! I think that the trickiest thing to figure out will be how to convey the JSON query in the URL, as well as what we should query the DB with. I think the solution you mentioned could work, but part of me wants to be able to just supply a JSON blob and do a partial match (similar to the Jest .toMatchObject method the whole way through...

@avatarneil avatarneil added the enhancement New feature or request label Mar 30, 2022
@mrsimpson
Copy link
Author

mrsimpson commented Mar 30, 2022

I thought so too, but partial matching an object is not really what queries are about (in general). I'd expect a JSON-object in the query parameter to describe the query, not the target partial object.
When it comes to formulating a query in json, I am actually quite happy with MongoDBs query document syntax. Funny enough, I just found a zero dependencies npm library which converts mongo queries to PostgreSQLs jsonb.
Looks like I am at least not the only fan of that idea ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants