delete endpoint

This commit is contained in:
2026-03-20 17:28:13 +05:00
parent afe14fa2fa
commit e5a80c8ae7
2 changed files with 67 additions and 3 deletions

View File

@@ -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 {