Is your feature request related to a problem? Please describe.
When querying data with pgx, I can quite easily load the data into structs using the various RowTo functions.
However, when inserting data, I have to repeat field names a lot:
_, err := c.db.Exec(ctx, `
INSERT INTO foo (col)
VALUES (@col)
`, pgx.StrictNamedArgs{
"col": m.Col,
})
Describe the solution you'd like
A feature similar to (Strict)NamedArgs, but instead of passing a map, passing a struct with the appropriate struct tags:
type Foo struct {
Col string `db:"col"`
}
_, err := c.db.Exec(ctx, `
INSERT INTO foo (col)
VALUES (@col)
`, pgx.StructArgs(m))
Describe alternatives you've considered
None.
Additional context
None.
Is your feature request related to a problem? Please describe.
When querying data with pgx, I can quite easily load the data into structs using the various RowTo functions.
However, when inserting data, I have to repeat field names a lot:
Describe the solution you'd like
A feature similar to (Strict)NamedArgs, but instead of passing a map, passing a struct with the appropriate struct tags:
Describe alternatives you've considered
None.
Additional context
None.