delete endpoint
This commit is contained in:
@@ -132,12 +132,16 @@ func Update[T any](ctx context.Context, table string, item T, db Querier, opts .
|
||||
return nil
|
||||
}
|
||||
|
||||
func Delete[T any](ctx context.Context, table string, db Querier, opts ...func(*sqlbuilder.SelectBuilder)) error {
|
||||
func Delete[T any](ctx context.Context, table string, db Querier, opts ...func(*sqlbuilder.DeleteBuilder)) error {
|
||||
structs := sqlbuilder.NewStruct(new(T))
|
||||
|
||||
sb := structs.WithoutTag("db", "-").DeleteFrom(table)
|
||||
sb.SetFlavor(sqlbuilder.PostgreSQL)
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(sb)
|
||||
}
|
||||
|
||||
query, args := sb.Build()
|
||||
|
||||
if _, err := db.Exec(ctx, query, args...); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user