fixed errors
This commit is contained in:
parent
a1e118f200
commit
cfeb6940fb
@ -28,17 +28,14 @@ func UpdateUserByNameEncoder(u *User, encode EncodeFunc) error {
|
||||
}
|
||||
|
||||
func TestDB(t *testing.T) {
|
||||
db, err := NewMysqlDatabase("ip", 3306, "username", "password", "database")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
db := NewMysqlDatabase("ip", 3306, "username", "password", "database")
|
||||
defer db.Close()
|
||||
|
||||
insertUser := Insert(db, "INSERT INTO users VALUES (?, ?, ?)", InsertUserEncoder)
|
||||
|
||||
updateUser := Update(db, "UPDATE users SET salt = ? WHERE name = ?", UpdateUserByNameEncoder)
|
||||
|
||||
getUsers := Query(db, "SELECT * FROM users WHERE name = ?", UserDecoder)
|
||||
getUsers := QueryMany(db, "SELECT * FROM users WHERE name = ?", UserDecoder)
|
||||
|
||||
pw := sha512.Sum512([]byte("weiter"))
|
||||
timon := &User{
|
||||
|
@ -1,10 +1,7 @@
|
||||
package advsql
|
||||
|
||||
func Insert[T any](db *Database, query string, encoder func(v *T, encode EncodeFunc) error) InsertFunc[T] {
|
||||
s, err := db.prepare(query)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s := db.prepare(query)
|
||||
|
||||
return func(value *T) error {
|
||||
return encoder(value, func(args ...interface{}) error {
|
||||
|
Loading…
Reference in New Issue
Block a user