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) {
|
func TestDB(t *testing.T) {
|
||||||
db, err := NewMysqlDatabase("ip", 3306, "username", "password", "database")
|
db := NewMysqlDatabase("ip", 3306, "username", "password", "database")
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
insertUser := Insert(db, "INSERT INTO users VALUES (?, ?, ?)", InsertUserEncoder)
|
insertUser := Insert(db, "INSERT INTO users VALUES (?, ?, ?)", InsertUserEncoder)
|
||||||
|
|
||||||
updateUser := Update(db, "UPDATE users SET salt = ? WHERE name = ?", UpdateUserByNameEncoder)
|
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"))
|
pw := sha512.Sum512([]byte("weiter"))
|
||||||
timon := &User{
|
timon := &User{
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package advsql
|
package advsql
|
||||||
|
|
||||||
func Insert[T any](db *Database, query string, encoder func(v *T, encode EncodeFunc) error) InsertFunc[T] {
|
func Insert[T any](db *Database, query string, encoder func(v *T, encode EncodeFunc) error) InsertFunc[T] {
|
||||||
s, err := db.prepare(query)
|
s := db.prepare(query)
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return func(value *T) error {
|
return func(value *T) error {
|
||||||
return encoder(value, func(args ...interface{}) error {
|
return encoder(value, func(args ...interface{}) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user