14 lines
313 B
Go
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
|
|
})
|
|
}
|
|
}
|