13 lines
289 B
Go
13 lines
289 B
Go
package advsql
|
|
|
|
func Insert[T any](db *Database, query string, encoder func(v *T, encode ScanFunc) error) InsertFunc[T] {
|
|
s := db.prepare(query)
|
|
|
|
return func(value *T) error {
|
|
return encoder(value, func(args ...interface{}) error {
|
|
_, err := s.Exec(args...)
|
|
return err
|
|
})
|
|
}
|
|
}
|