Example usage of AIP160 filtering
pigfrown opened this issue · comments
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
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:
- Declare the filtering API using
filtering.NewDeclarations
using protobuf names and casing (i.e. field_name) - Parse filter in request using
filtering.ParseFilter
- Validate parsed filter using matchers from
exprs
sub-package. One example here. - Rewrite filter to match database schema using
filtering.ApplyMacros
- Transpile
filtering.Filter
to a format used by the database "drivers". For an example see how it is done in spanner-aip-go
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
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:
- Declare the filtering API using
filtering.NewDeclarations
using protobuf names and casing (i.e. field_name)- Parse filter in request using
filtering.ParseFilter
- Validate parsed filter using matchers from
exprs
sub-package. One example here.- Rewrite filter to match database schema using
filtering.ApplyMacros
- 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.
@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!
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.
This issue has been open for 365 days with no activity. Marking as stale.