6
6
"github.com/lann/builder"
7
7
)
8
8
9
+ // ErrEmptyTable is a common database/sql error if a table is empty or no rows is returned by the query.
9
10
var ErrEmptyTable = errors .New ("sql: no rows in result set" )
11
+ // ErrEmptyTable is a common pgx error if a table is empty or no rows is returned by the query.
10
12
var ErrEmptyTablePgx = errors .New ("no rows in result set" )
11
13
12
14
// BobBuilderType is the type for BobBuilder
@@ -22,6 +24,7 @@ func (b BobBuilderType) CreateTable(table string) CreateBuilder {
22
24
return CreateBuilder (b ).Name (table )
23
25
}
24
26
27
+ // CreateTableIfNotExists creates a table with CreateBuilder interface, if the table doesn't exists.
25
28
func (b BobBuilderType ) CreateTableIfNotExists (table string ) CreateBuilder {
26
29
return CreateBuilder (b ).Name (table ).IfNotExists ()
27
30
}
@@ -36,57 +39,65 @@ func (b BobBuilderType) HasColumn(column string) HasBuilder {
36
39
return HasBuilder (b ).HasColumn (column )
37
40
}
38
41
42
+ // DropTable drops (delete contents & remove) a table from the database.
39
43
func (b BobBuilderType ) DropTable (table string ) DropBuilder {
40
44
return DropBuilder (b ).DropTable (table )
41
45
}
42
46
47
+ // DropTable drops (delete contents & remove) a table from the database if the table exists.
43
48
func (b BobBuilderType ) DropTableIfExists (table string ) DropBuilder {
44
49
return DropBuilder (b ).DropTable (table ).IfExists ()
45
50
}
46
51
52
+ // RenameTable simply renames an exisisting table.
47
53
func (b BobBuilderType ) RenameTable (from , to string ) RenameBuilder {
48
54
return RenameBuilder (b ).From (from ).To (to )
49
55
}
50
56
57
+ // Truncate performs TRUNCATE function. It deletes all contents from a table but not deleting the table.
51
58
func (b BobBuilderType ) Truncate (table string ) TruncateBuilder {
52
59
return TruncateBuilder (b ).Truncate (table )
53
60
}
54
61
55
62
// BobStmtBuilder is the parent builder for BobBuilderType
56
63
var BobStmtBuilder = BobBuilderType (builder .EmptyBuilder )
57
64
58
- // CreateTable creates a table with CreateBuilder interface
65
+ // CreateTable creates a table with CreateBuilder interface.
59
66
func CreateTable (table string ) CreateBuilder {
60
67
return BobStmtBuilder .CreateTable (table )
61
68
}
62
69
63
- // CreateTableIfNotExists creates a table with CreateBuilder interface, if the table doesn't exists
70
+ // CreateTableIfNotExists creates a table with CreateBuilder interface, if the table doesn't exists.
64
71
func CreateTableIfNotExists (table string ) CreateBuilder {
65
72
return BobStmtBuilder .CreateTableIfNotExists (table )
66
73
}
67
74
68
- // HasTable checks if a table exists with HasBuilder interface
75
+ // HasTable checks if a table exists with HasBuilder interface.
69
76
func HasTable (table string ) HasBuilder {
70
77
return BobStmtBuilder .HasTable (table )
71
78
}
72
79
73
- // HasColumn checks if a column exists with HasBuilder interface
80
+ // HasColumn checks if a column exists with HasBuilder interface.
74
81
func HasColumn (col string ) HasBuilder {
75
82
return BobStmtBuilder .HasColumn (col )
76
83
}
77
84
85
+ // DropTable drops (delete contents & remove) a table from the database.
78
86
func DropTable (table string ) DropBuilder {
79
87
return BobStmtBuilder .DropTable (table )
80
88
}
81
89
90
+ // DropTable drops (delete contents & remove) a table from the database if the table exists.
82
91
func DropTableIfExists (table string ) DropBuilder {
83
92
return BobStmtBuilder .DropTableIfExists (table )
84
93
}
85
94
95
+ // RenameTable simply renames an exisisting table.
86
96
func RenameTable (from , to string ) RenameBuilder {
87
97
return BobStmtBuilder .RenameTable (from , to )
88
98
}
89
99
100
+ // Truncate performs TRUNCATE function. It deletes all contents from a table but not deleting the table.
90
101
func Truncate (table string ) TruncateBuilder {
91
102
return BobStmtBuilder .Truncate (table )
92
103
}
0 commit comments