@@ -8,78 +8,107 @@ import (
88)
99
1010type (
11- Safe = schema.Safe
12- Name = schema.Name
11+ // Safe marks a SQL fragment as trusted and prevents further escaping.
12+ Safe = schema.Safe
13+ // Name represents a SQL identifier such as a column or table name.
14+ Name = schema.Name
15+ // Ident is a fully qualified SQL identifier.
1316 Ident = schema.Ident
17+ // Order denotes sorting direction used in ORDER BY clauses.
1418 Order = schema.Order
1519
16- NullTime = schema.NullTime
20+ // NullTime is a nullable time value compatible with Bun.
21+ NullTime = schema.NullTime
22+ // BaseModel provides default metadata embedded into user models.
1723 BaseModel = schema.BaseModel
18- Query = schema.Query
24+ // Query is implemented by all Bun query builders.
25+ Query = schema.Query
1926
27+ // BeforeAppendModelHook is called before a model is appended to a query.
2028 BeforeAppendModelHook = schema.BeforeAppendModelHook
2129
30+ // BeforeScanRowHook runs before scanning an individual row.
2231 BeforeScanRowHook = schema.BeforeScanRowHook
23- AfterScanRowHook = schema.AfterScanRowHook
32+ // AfterScanRowHook runs after scanning an individual row.
33+ AfterScanRowHook = schema.AfterScanRowHook
2434)
2535
2636const (
27- OrderAsc = schema .OrderAsc
28- OrderAscNullsFirst = schema .OrderDesc
29- OrderAscNullsLast = schema .OrderAscNullsLast
30- OrderDesc = schema .OrderDesc
37+ // OrderAsc sorts values in ascending order.
38+ OrderAsc = schema .OrderAsc
39+ // OrderAscNullsFirst sorts ascending with NULL values first.
40+ OrderAscNullsFirst = schema .OrderDesc
41+ // OrderAscNullsLast sorts ascending with NULL values last.
42+ OrderAscNullsLast = schema .OrderAscNullsLast
43+ // OrderDesc sorts values in descending order.
44+ OrderDesc = schema .OrderDesc
45+ // OrderDescNullsFirst sorts descending with NULL values first.
3146 OrderDescNullsFirst = schema .OrderDescNullsFirst
32- OrderDescNullsLast = schema .OrderDescNullsLast
47+ // OrderDescNullsLast sorts descending with NULL values last.
48+ OrderDescNullsLast = schema .OrderDescNullsLast
3349)
3450
51+ // SafeQuery wraps a raw query string and arguments and marks it safe for Bun.
3552func SafeQuery (query string , args ... any ) schema.QueryWithArgs {
3653 return schema .SafeQuery (query , args )
3754}
3855
56+ // BeforeSelectHook is invoked before executing SELECT queries.
3957type BeforeSelectHook interface {
4058 BeforeSelect (ctx context.Context , query * SelectQuery ) error
4159}
4260
61+ // AfterSelectHook is invoked after executing SELECT queries.
4362type AfterSelectHook interface {
4463 AfterSelect (ctx context.Context , query * SelectQuery ) error
4564}
4665
66+ // BeforeInsertHook is invoked before executing INSERT queries.
4767type BeforeInsertHook interface {
4868 BeforeInsert (ctx context.Context , query * InsertQuery ) error
4969}
5070
71+ // AfterInsertHook is invoked after executing INSERT queries.
5172type AfterInsertHook interface {
5273 AfterInsert (ctx context.Context , query * InsertQuery ) error
5374}
5475
76+ // BeforeUpdateHook is invoked before executing UPDATE queries.
5577type BeforeUpdateHook interface {
5678 BeforeUpdate (ctx context.Context , query * UpdateQuery ) error
5779}
5880
81+ // AfterUpdateHook is invoked after executing UPDATE queries.
5982type AfterUpdateHook interface {
6083 AfterUpdate (ctx context.Context , query * UpdateQuery ) error
6184}
6285
86+ // BeforeDeleteHook is invoked before executing DELETE queries.
6387type BeforeDeleteHook interface {
6488 BeforeDelete (ctx context.Context , query * DeleteQuery ) error
6589}
6690
91+ // AfterDeleteHook is invoked after executing DELETE queries.
6792type AfterDeleteHook interface {
6893 AfterDelete (ctx context.Context , query * DeleteQuery ) error
6994}
7095
96+ // BeforeCreateTableHook is invoked before executing CREATE TABLE queries.
7197type BeforeCreateTableHook interface {
7298 BeforeCreateTable (ctx context.Context , query * CreateTableQuery ) error
7399}
74100
101+ // AfterCreateTableHook is invoked after executing CREATE TABLE queries.
75102type AfterCreateTableHook interface {
76103 AfterCreateTable (ctx context.Context , query * CreateTableQuery ) error
77104}
78105
106+ // BeforeDropTableHook is invoked before executing DROP TABLE queries.
79107type BeforeDropTableHook interface {
80108 BeforeDropTable (ctx context.Context , query * DropTableQuery ) error
81109}
82110
111+ // AfterDropTableHook is invoked after executing DROP TABLE queries.
83112type AfterDropTableHook interface {
84113 AfterDropTable (ctx context.Context , query * DropTableQuery ) error
85114}
@@ -89,10 +118,12 @@ func SetLogger(logger internal.Logging) {
89118 internal .SetLogger (logger )
90119}
91120
121+ // In wraps a slice so it can be used with the IN clause.
92122func In (slice any ) schema.QueryAppender {
93123 return schema .In (slice )
94124}
95125
126+ // NullZero forces zero values to be treated as NULL when building queries.
96127func NullZero (value any ) schema.QueryAppender {
97128 return schema .NullZero (value )
98129}
0 commit comments