Ejemplo n.º 1
0
func Sort(pairs map[string]string) bongo.Scope {
	return func(d *gorm.DB) *gorm.DB {
		for field, value := range pairs {
			q := fmt.Sprintf("%s %s", gorm.ToSnake(field), value)
			d = d.Order(q)
		}

		return d
	}
}
Ejemplo n.º 2
0
// TODO i am not sure about its place, maybe these must be moved to bongo
func ExcludeFields(pairs map[string]interface{}) bongo.Scope {
	return func(d *gorm.DB) *gorm.DB {
		for field, value := range pairs {

			q := fmt.Sprintf("%s <> ?", gorm.ToSnake(field))
			d = d.Where(q, value)
		}

		return d
	}
}