storj/satellite/satellitedb/dbx/templates/golang.get-first.tmpl
JT Olio d3b0691bbd satellite/dbx: import dbx templates
these are unchanged from storj.io/dbx.

we're importing them because in a later commit we
will change them, and it'd be nice to see that
diff as a separate commit.

Change-Id: I8315130ed6bab397bd65b9a1a90c29d130b8c02d
2020-11-29 18:09:33 -07:00

41 lines
855 B
Cheetah

{{- define "signature" -}}
First_{{ .Suffix }}({{ ctxparam .Args }}) (
{{ param .Row }}, err error)
{{- end -}}
{{- define "invoke" -}}
First_{{ .Suffix }}({{ ctxarg .Args }})
{{- end -}}
{{- define "body" }}
{{ embedplaceholders .Info }}
{{ embedsql .Info "__embed_stmt" }}
var __values []interface{}
{{ embedvalues .Args "__values" }}
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()
if !__rows.Next() {
if err := __rows.Err(); err != nil {
return nil, obj.makeErr(err)
}
return nil, nil
}
{{ init .Row }}
err = __rows.Scan({{ addrof (flatten .Row) }})
if err != nil {
return nil, obj.makeErr(err)
}
return {{ arg .Row }}, nil
{{ end -}}