2021-08-25 13:34:33 +00:00
|
|
|
package bun
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2021-09-08 19:05:26 +00:00
|
|
|
"github.com/uptrace/bun/internal"
|
2021-08-25 13:34:33 +00:00
|
|
|
"github.com/uptrace/bun/schema"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
Safe = schema.Safe
|
|
|
|
Ident = schema.Ident
|
2023-09-11 13:16:52 +00:00
|
|
|
Name = schema.Name
|
2021-08-25 13:34:33 +00:00
|
|
|
|
2021-09-08 19:05:26 +00:00
|
|
|
NullTime = schema.NullTime
|
|
|
|
BaseModel = schema.BaseModel
|
2021-10-24 11:14:37 +00:00
|
|
|
Query = schema.Query
|
2021-08-25 13:34:33 +00:00
|
|
|
|
2021-10-24 11:14:37 +00:00
|
|
|
BeforeAppendModelHook = schema.BeforeAppendModelHook
|
|
|
|
|
|
|
|
BeforeScanRowHook = schema.BeforeScanRowHook
|
|
|
|
AfterScanRowHook = schema.AfterScanRowHook
|
2021-08-25 13:34:33 +00:00
|
|
|
)
|
|
|
|
|
2024-11-08 13:51:23 +00:00
|
|
|
func SafeQuery(query string, args ...interface{}) schema.QueryWithArgs {
|
|
|
|
return schema.SafeQuery(query, args)
|
|
|
|
}
|
|
|
|
|
2021-08-25 13:34:33 +00:00
|
|
|
type BeforeSelectHook interface {
|
|
|
|
BeforeSelect(ctx context.Context, query *SelectQuery) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type AfterSelectHook interface {
|
|
|
|
AfterSelect(ctx context.Context, query *SelectQuery) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type BeforeInsertHook interface {
|
|
|
|
BeforeInsert(ctx context.Context, query *InsertQuery) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type AfterInsertHook interface {
|
|
|
|
AfterInsert(ctx context.Context, query *InsertQuery) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type BeforeUpdateHook interface {
|
|
|
|
BeforeUpdate(ctx context.Context, query *UpdateQuery) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type AfterUpdateHook interface {
|
|
|
|
AfterUpdate(ctx context.Context, query *UpdateQuery) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type BeforeDeleteHook interface {
|
|
|
|
BeforeDelete(ctx context.Context, query *DeleteQuery) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type AfterDeleteHook interface {
|
|
|
|
AfterDelete(ctx context.Context, query *DeleteQuery) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type BeforeCreateTableHook interface {
|
|
|
|
BeforeCreateTable(ctx context.Context, query *CreateTableQuery) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type AfterCreateTableHook interface {
|
|
|
|
AfterCreateTable(ctx context.Context, query *CreateTableQuery) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type BeforeDropTableHook interface {
|
|
|
|
BeforeDropTable(ctx context.Context, query *DropTableQuery) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type AfterDropTableHook interface {
|
|
|
|
AfterDropTable(ctx context.Context, query *DropTableQuery) error
|
|
|
|
}
|
2021-09-08 19:05:26 +00:00
|
|
|
|
2024-11-08 13:51:23 +00:00
|
|
|
// SetLogger overwrites default Bun logger.
|
2021-09-08 19:05:26 +00:00
|
|
|
func SetLogger(logger internal.Logging) {
|
2024-04-15 10:01:20 +00:00
|
|
|
internal.SetLogger(logger)
|
2021-09-08 19:05:26 +00:00
|
|
|
}
|
2021-08-25 13:34:33 +00:00
|
|
|
|
2022-04-24 10:26:22 +00:00
|
|
|
func In(slice interface{}) schema.QueryAppender {
|
|
|
|
return schema.In(slice)
|
2021-08-25 13:34:33 +00:00
|
|
|
}
|
2023-09-11 13:16:52 +00:00
|
|
|
|
|
|
|
func NullZero(value interface{}) schema.QueryAppender {
|
|
|
|
return schema.NullZero(value)
|
|
|
|
}
|