Ever wanted to filter objects on a deep level using only maps? This plugin allows you to do just that.
package main
func main () {
filters := map[string]any{
"name": "abc",
"related_object": map[string]any{
"title": "engineer",
},
}
}
Is automatically turned into a query that looks like this:
SELECT * FROM employees WHERE related_object_id IN (SELECT id FROM occupations WHERE title = "engineer")
- gormlike turns WHERE-calls into LIkE queries if certain tokens were found
- gormqonvert turns WHERE-calls into different queries if certain tokens were found
- gormcase adds case insensitivity to WHERE queries
- gormtestutil provides easy utility methods for unit-testing with gorm
go get github.com/survivorbat/gorm-deep-filtering
package main
import (
"github.com/survivorbat/gorm-deep-filtering"
)
func main() {
db, _ := gorm.Open(sqlite.Open("test.db"), &gorm.Config{})
// Adds deep filtering
db.Use(deepgorm.New())
}
Better error handling, logging.