GOLF (WIP)
GOLF(Go Light Filter), golf dependents Gorm and Gin. golf can help you build model query as fast as,build model query like Django Rest Framework.
usage
define model
type testModel struct {
ID int `json:"id"`
UserID int `json:"user_id"`
Username string `json:"username"`
}
Golf Query
implement use golf must implement this interface , map key is go struct member name
func (m *testModel) Field() map[string][]golf.Filter {
return map[string][]golf.Filter{
"ID": {golf.Equal},
"UserID": {golf.Equal, golf.Gte},
"Username": {golf.Equal, golf.Like},
}
}
use with Gin
TODO you can read the example
// URL path /ping?eq_id=1&like_username=test
// sql log should be SELECT * FROM "test_model" WHERE username LIKE 'test' AND id = 1 LIMIT 10