|
|
|
@ -17,30 +17,40 @@ type Builder struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewBuilder(token string) *Builder {
|
|
|
|
|
return &Builder{[]string{fmt.Sprintf("api=%s", token)}}
|
|
|
|
|
return &Builder{[]string{fmt.Sprintf("api=%v", token)}}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) QueryString() string {
|
|
|
|
|
return "?" + strings.Join(db.Params, "&")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Exact(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__exact=%s", field, value))
|
|
|
|
|
func (db *Builder) Eq(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%__eq=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) IExact(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__iexact=%s", field, value))
|
|
|
|
|
func (db *Builder) Ne(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__ne=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Contains(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__contains=%s", field, value))
|
|
|
|
|
func (db *Builder) Exact(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__exact=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) IContains(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__icontains=%s", field, value))
|
|
|
|
|
func (db *Builder) IExact(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__iexact=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Contains(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__contains=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) IContains(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__icontains=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -49,43 +59,43 @@ func (db *Builder) In(field string, values ...string) *Builder {
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Gt(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__gt=%s", field, value))
|
|
|
|
|
func (db *Builder) Gt(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__gt=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Gte(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__gte=%s", field, value))
|
|
|
|
|
func (db *Builder) Gte(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__gte=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Lt(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__lt=%s", field, value))
|
|
|
|
|
func (db *Builder) Lt(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__lt=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Lte(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__lte=%s", field, value))
|
|
|
|
|
func (db *Builder) Lte(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__lte=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Startswith(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__startswith=%s", field, value))
|
|
|
|
|
func (db *Builder) Startswith(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__startswith=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) IStartswith(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__istartswith=%s", field, value))
|
|
|
|
|
func (db *Builder) IStartswith(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__istartswith=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Endswith(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__endswith=%s", field, value))
|
|
|
|
|
func (db *Builder) Endswith(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__endswith=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) IEndswith(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__iendswith=%s", field, value))
|
|
|
|
|
func (db *Builder) IEndswith(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__iendswith=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -94,72 +104,72 @@ func (db *Builder) Range(field Field, from, to string) *Builder {
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Date(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__date=%s", field, value))
|
|
|
|
|
func (db *Builder) Date(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__date=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Year(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__year=%s", field, value))
|
|
|
|
|
func (db *Builder) Year(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__year=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Month(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__month=%s", field, value))
|
|
|
|
|
func (db *Builder) Month(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__month=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Day(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__day=%s", field, value))
|
|
|
|
|
func (db *Builder) Day(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__day=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Week(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__week=%s", field, value))
|
|
|
|
|
func (db *Builder) Week(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__week=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) WeekDay(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__week_day=%s", field, value))
|
|
|
|
|
func (db *Builder) WeekDay(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__week_day=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Quarter(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__quarter=%s", field, value))
|
|
|
|
|
func (db *Builder) Quarter(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__quarter=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Time(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__time=%s", field, value))
|
|
|
|
|
func (db *Builder) Time(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__time=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Hour(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__hour=%s", field, value))
|
|
|
|
|
func (db *Builder) Hour(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__hour=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Minute(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__minute=%s", field, value))
|
|
|
|
|
func (db *Builder) Minute(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__minute=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Second(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__second=%s", field, value))
|
|
|
|
|
func (db *Builder) Second(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__second=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) IsNull(field Field, value string) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__isnull=%s", field, value))
|
|
|
|
|
func (db *Builder) IsNull(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__isnull=%v", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) Regex(field Field, value string) *Builder {
|
|
|
|
|
func (db *Builder) Regex(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__regex=r'%s'", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (db *Builder) IRegex(field Field, value string) *Builder {
|
|
|
|
|
func (db *Builder) IRegex(field Field, value interface{}) *Builder {
|
|
|
|
|
db.Params = append(db.Params, fmt.Sprintf("%s__iregex=r'%s'", field, value))
|
|
|
|
|
return db
|
|
|
|
|
}
|
|
|
|
|