further optimized database calls to replace all single-value QueryRowContext calls with GetContext

This commit is contained in:
2026-02-23 18:21:38 -07:00
parent 4113ba2fca
commit 220e1ecc98
14 changed files with 233 additions and 290 deletions
+2 -4
View File
@@ -61,8 +61,7 @@ func (img *ImageStore) Save(ctx context.Context) error {
*/
func AmLoadImage(ctx context.Context, id int32) (*ImageStore, error) {
var imgdata ImageStore
err := amdb.GetContext(ctx, &imgdata, "SELECT * FROM imagestore WHERE imgid = ?", id)
if err != nil {
if err := amdb.GetContext(ctx, &imgdata, "SELECT * FROM imagestore WHERE imgid = ?", id); err != nil {
return nil, err
}
return &imgdata, nil
@@ -81,9 +80,8 @@ func AmLoadImage(ctx context.Context, id int32) (*ImageStore, error) {
*/
func AmStoreImage(ctx context.Context, typecode int16, owner int32, mimetype string, data []byte) (*ImageStore, error) {
var img *ImageStore
row := amdb.QueryRowContext(ctx, "SELECT imgid FROM imagestore WHERE typecode = ? AND ownerid = ?", typecode, owner)
var id int32
err := row.Scan(&id)
err := amdb.GetContext(ctx, &id, "SELECT imgid FROM imagestore WHERE typecode = ? AND ownerid = ?", typecode, owner)
switch err {
case nil:
img, err = AmLoadImage(ctx, id)