https://github.com/survivorbat/gorm-deep-filtering
Allow gorm's Where() to take in maps of maps that are automatically converted into subqueries
https://github.com/survivorbat/gorm-deep-filtering
deep deep-filter deep-filtering deep-map filter filtering go go-map go-orm golang gorm gorm-orm gorm-plugin many-to-many many-to-one map map-deep multi-query one-to-many
Last synced: about 1 month ago
JSON representation
Allow gorm's Where() to take in maps of maps that are automatically converted into subqueries
- Host: GitHub
- URL: https://github.com/survivorbat/gorm-deep-filtering
- Owner: survivorbat
- License: mit
- Created: 2022-10-16T12:10:17.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-13T16:46:47.000Z (2 months ago)
- Last Synced: 2025-04-14T16:14:31.256Z (about 1 month ago)
- Topics: deep, deep-filter, deep-filtering, deep-map, filter, filtering, go, go-map, go-orm, golang, gorm, gorm-orm, gorm-plugin, many-to-many, many-to-one, map, map-deep, multi-query, one-to-many
- Language: Go
- Homepage: https://pkg.go.dev/github.com/survivorbat/gorm-deep-filtering
- Size: 97.7 KB
- Stars: 11
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🌌 Gorm Deep Filtering Plugin
[](https://github.com/survivorbat/gorm-deep-filtering/actions/workflows/test.yaml)

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