From c362b6bc33d09649accf52be0f1ea3ee307dd7fa Mon Sep 17 00:00:00 2001 From: ycc Date: Fri, 7 Jul 2023 09:15:22 +0200 Subject: [PATCH] result to map --- db.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/db.go b/db.go index b938778..98002ba 100755 --- a/db.go +++ b/db.go @@ -697,3 +697,13 @@ func FormatForSQL(datatype string, value interface{}) string { } return fmt.Sprint(strval) } + +// Build a map based on id from a query result +func (db *Db) BuildIdMap(idxkey string, rows Rows) (map[int64]AssRow, error) { + ht := make(map[int64]AssRow) + for _, row := range rows { + id := row[idxkey].(int64) + ht[id] = row + } + return ht, nil +}