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

Example usage of AIP160 filtering #97

Open
pigfrown opened this issue Nov 10, 2021 · 6 comments
Open

Example usage of AIP160 filtering #97

pigfrown opened this issue Nov 10, 2021 · 6 comments
Labels

Comments

@pigfrown
Copy link

Hi, is there any example of how to use the filtering part of this package? Or if no example, a brief explanation of how it works.

Thanks

@ericwenn
Copy link
Member

Hello!

As you might have noticed the filtering package in aip-go is not an end to end implementation for filtering, rather it
is a set of utilities to use when building your own filtering.

The typical usage in internal services at Einride looks something like this:

  1. Declare the filtering API using filtering.NewDeclarations using protobuf names and casing (i.e. field_name)
  2. Parse filter in request using filtering.ParseFilter
  3. Validate parsed filter using matchers from exprs sub-package. One example here.
  4. Rewrite filter to match database schema using filtering.ApplyMacros
  5. Transpile filtering.Filter to a format used by the database "drivers". For an example see how it is done in spanner-aip-go

@newtonnthiga
Copy link

Hello

Might be a good idea to open up a discussions tab for these kind of questions/support, I'll just ask here in the meantime.

When declaring Idents, how do you declare a custom type. For example google.golang.org/genproto/googleapis/type/dayofweek or google.golang.org/genproto/googleapis/type/money

@27149chen
Copy link

27149chen commented Jul 16, 2022

Hello!

As you might have noticed the filtering package in aip-go is not an end to end implementation for filtering, rather it is a set of utilities to use when building your own filtering.

The typical usage in internal services at Einride looks something like this:

  1. Declare the filtering API using filtering.NewDeclarations using protobuf names and casing (i.e. field_name)
  2. Parse filter in request using filtering.ParseFilter
  3. Validate parsed filter using matchers from exprs sub-package. One example here.
  4. Rewrite filter to match database schema using filtering.ApplyMacros
  5. Transpile filtering.Filter to a format used by the database "drivers". For an example see how it is done in spanner-aip-go

@ericwenn can you please write at least one e2e example to use filtering, I feel a little confused :(
Thank you very much.

@mindcrackx
Copy link

@ericwenn hi, first of all thanks for this great library!
Still trying to wrap my head around the filtering. Would it be possible for you to add an example on how to transpile the filtering.Filter into an sql query for example postgresql? Would it make sense to use a query builder like squirrel?
I can't seem to rewrite the spanner-api-go example to make postgresql queries.
And of course an e2e example with getting and validating a request with filtering to querying a sql database would be the dream!
Keep up the great work!

@andresuribe87
Copy link

Here's an example of filtering being done in-memory: TBD54566975/ssi-service#197

Hope that helps! Keep in mind that transpiling is a much better approach, as it leverages the underlying db tech.

Copy link

github-actions bot commented Apr 8, 2024

This issue has been open for 365 days with no activity. Marking as stale.

@github-actions github-actions bot added the Stale label Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants