u
This commit is contained in:
1 parent
f59d5c4f59
commit
b1348343c9
24 files changed
+1691
-1243
No files matched your search
@@ -7,18 +7,28 @@ import (
|
||||
)
|
||||
|
||||
func (c *Client) Delete(ctx context.Context, table, keyField string, data map[string]any) error {
|
||||
keyVal, err := validateData(table, keyField, data)
|
||||
_, err := validateData(table, keyField, data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
where := make([]string, 0, len(data))
|
||||
args := make([]any, 0, len(data))
|
||||
i := 1
|
||||
|
||||
for k, v := range data {
|
||||
where = append(where, fmt.Sprintf("%s = $%d", quoteCol(k), i))
|
||||
args = append(args, v)
|
||||
i++
|
||||
}
|
||||
|
||||
sql := fmt.Sprintf(
|
||||
"DELETE FROM %s WHERE %s=$1",
|
||||
"DELETE FROM %s WHERE %s",
|
||||
quoteTable(table),
|
||||
quoteCol(keyField),
|
||||
strings.Join(where, " AND "),
|
||||
)
|
||||
|
||||
_, err = c.exec().Exec(ctx, sql, keyVal)
|
||||
_, err = c.exec().Exec(ctx, sql, args...)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ func VerifyToken(ctx context.Context, tokenString string) (*CustomClaims, bool)
|
||||
}
|
||||
|
||||
claims, ok := token.Claims.(*CustomClaims)
|
||||
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user