42 lines
965 B
Cheetah
42 lines
965 B
Cheetah
|
{{- define "signature" -}}
|
||
|
Limited_{{ .Suffix }}({{ ctxparam .Args }},
|
||
|
limit int, offset int64) (
|
||
|
rows {{ sliceof .Row }}, err error)
|
||
|
{{- end -}}
|
||
|
|
||
|
|
||
|
{{- define "invoke" -}}
|
||
|
Limited_{{ .Suffix }}({{ ctxarg .Args }}, limit, offset)
|
||
|
{{- end -}}
|
||
|
|
||
|
{{- define "body" }}
|
||
|
{{ embedplaceholders .Info }}
|
||
|
{{ embedsql .Info "__embed_stmt" }}
|
||
|
|
||
|
var __values []interface{}
|
||
|
{{ embedvalues .Args "__values" }}
|
||
|
__values = append(__values, limit, offset)
|
||
|
|
||
|
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
|
||
|
obj.logStmt(__stmt, __values...)
|
||
|
|
||
|
__rows, err := obj.driver.QueryContext(ctx, __stmt, __values...)
|
||
|
if err != nil {
|
||
|
return nil, obj.makeErr(err)
|
||
|
}
|
||
|
defer __rows.Close()
|
||
|
|
||
|
for __rows.Next() {
|
||
|
{{ initnew .Row }}
|
||
|
err = __rows.Scan({{ addrof (flatten .Row) }})
|
||
|
if err != nil {
|
||
|
return nil, obj.makeErr(err)
|
||
|
}
|
||
|
rows = append(rows, {{ arg .Row }})
|
||
|
}
|
||
|
if err := __rows.Err(); err != nil {
|
||
|
return nil, obj.makeErr(err)
|
||
|
}
|
||
|
return rows, nil
|
||
|
{{ end -}}
|