Skip to content

Commit be3c0aa

Browse files
committed
added db.InsertStruct
1 parent 5e0cfc5 commit be3c0aa

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

db/query.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,10 @@ func QueryStructSlice[S any](ctx context.Context, query string, args ...any) (ro
176176
}
177177
return rows, nil
178178
}
179+
180+
// InsertStruct inserts a new row into table using the connection's
181+
// StructFieldMapper to map struct fields to column names.
182+
// Optional ColumnFilter can be passed to ignore mapped columns.
183+
func InsertStruct(ctx context.Context, table string, rowStruct any, ignoreColumns ...sqldb.ColumnFilter) error {
184+
return Conn(ctx).InsertStruct(table, rowStruct, ignoreColumns...)
185+
}

0 commit comments

Comments
 (0)