advsql/insert.go
2022-07-12 20:56:33 +02:00

14 lines
313 B
Go

package advsql
func Insert[T any](db *Database, query string, encoder func(v *T, encode ScanFunc) error) InsertFunc[T] {
prepareGlobal(db, query)
return func(value *T) error {
s := db.stmt(query)
return encoder(value, func(args ...interface{}) error {
_, err := s.Exec(args...)
return err
})
}
}