mirror of https://github.com/aldy505/bob.git
refactor: clean up exported funcs
This commit is contained in:
parent
ecefcdb710
commit
49cf645a9e
12
bob.go
12
bob.go
|
@ -30,12 +30,12 @@ type BobBuilder interface {
|
|||
|
||||
// CreateTable creates a table with CreateBuilder interface
|
||||
func (b BobBuilderType) CreateTable(table string) CreateBuilder {
|
||||
return CreateBuilder(b).Name(table)
|
||||
return CreateBuilder(b).name(table)
|
||||
}
|
||||
|
||||
// CreateTableIfNotExists creates a table with CreateBuilder interface, if the table doesn't exists.
|
||||
func (b BobBuilderType) CreateTableIfNotExists(table string) CreateBuilder {
|
||||
return CreateBuilder(b).Name(table).IfNotExists()
|
||||
return CreateBuilder(b).name(table).ifNotExists()
|
||||
}
|
||||
|
||||
// HasTable checks if a table exists with HasBuilder interface
|
||||
|
@ -50,22 +50,22 @@ func (b BobBuilderType) HasColumn(column string) HasBuilder {
|
|||
|
||||
// DropTable drops (delete contents & remove) a table from the database.
|
||||
func (b BobBuilderType) DropTable(table string) DropBuilder {
|
||||
return DropBuilder(b).DropTable(table)
|
||||
return DropBuilder(b).dropTable(table)
|
||||
}
|
||||
|
||||
// DropTable drops (delete contents & remove) a table from the database if the table exists.
|
||||
func (b BobBuilderType) DropTableIfExists(table string) DropBuilder {
|
||||
return DropBuilder(b).DropTable(table).IfExists()
|
||||
return DropBuilder(b).dropTable(table).ifExists()
|
||||
}
|
||||
|
||||
// RenameTable simply renames an exisisting table.
|
||||
func (b BobBuilderType) RenameTable(from, to string) RenameBuilder {
|
||||
return RenameBuilder(b).From(from).To(to)
|
||||
return RenameBuilder(b).from(from).to(to)
|
||||
}
|
||||
|
||||
// Truncate performs TRUNCATE function. It deletes all contents from a table but not deleting the table.
|
||||
func (b BobBuilderType) Truncate(table string) TruncateBuilder {
|
||||
return TruncateBuilder(b).Truncate(table)
|
||||
return TruncateBuilder(b).truncate(table)
|
||||
}
|
||||
|
||||
func (b BobBuilderType) Upsert(table string, dialect int) UpsertBuilder {
|
||||
|
|
|
@ -27,13 +27,13 @@ func init() {
|
|||
builder.Register(CreateBuilder{}, createData{})
|
||||
}
|
||||
|
||||
// Name sets the table name
|
||||
func (b CreateBuilder) Name(name string) CreateBuilder {
|
||||
// name sets the table name
|
||||
func (b CreateBuilder) name(name string) CreateBuilder {
|
||||
return builder.Set(b, "TableName", name).(CreateBuilder)
|
||||
}
|
||||
|
||||
// IfNotExists adds IF NOT EXISTS to the query
|
||||
func (b CreateBuilder) IfNotExists() CreateBuilder {
|
||||
// ifNotExists adds IF NOT EXISTS to the query
|
||||
func (b CreateBuilder) ifNotExists() CreateBuilder {
|
||||
return builder.Set(b, "IfNotExists", true).(CreateBuilder)
|
||||
}
|
||||
|
||||
|
|
4
drop.go
4
drop.go
|
@ -19,11 +19,11 @@ func init() {
|
|||
}
|
||||
|
||||
// DropTable sets which table to be dropped
|
||||
func (b DropBuilder) DropTable(name string) DropBuilder {
|
||||
func (b DropBuilder) dropTable(name string) DropBuilder {
|
||||
return builder.Set(b, "TableName", name).(DropBuilder)
|
||||
}
|
||||
|
||||
func (b DropBuilder) IfExists() DropBuilder {
|
||||
func (b DropBuilder) ifExists() DropBuilder {
|
||||
return builder.Set(b, "IfExists", true).(DropBuilder)
|
||||
}
|
||||
|
||||
|
|
3
has.go
3
has.go
|
@ -8,9 +8,6 @@ import (
|
|||
"github.com/lann/builder"
|
||||
)
|
||||
|
||||
// TODO - The whole file is a todo
|
||||
// Meant to find two things: HasTable and HasColumn(s)
|
||||
|
||||
type HasBuilder builder.Builder
|
||||
|
||||
type hasData struct {
|
||||
|
|
|
@ -17,13 +17,13 @@ func init() {
|
|||
builder.Register(RenameBuilder{}, renameData{})
|
||||
}
|
||||
|
||||
// From sets existing table name
|
||||
func (b RenameBuilder) From(name string) RenameBuilder {
|
||||
// from sets existing table name
|
||||
func (b RenameBuilder) from(name string) RenameBuilder {
|
||||
return builder.Set(b, "From", name).(RenameBuilder)
|
||||
}
|
||||
|
||||
// To sets desired table name
|
||||
func (b RenameBuilder) To(name string) RenameBuilder {
|
||||
// to sets desired table name
|
||||
func (b RenameBuilder) to(name string) RenameBuilder {
|
||||
return builder.Set(b, "To", name).(RenameBuilder)
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ func init() {
|
|||
}
|
||||
|
||||
// Truncate sets which table to be dropped
|
||||
func (b TruncateBuilder) Truncate(name string) TruncateBuilder {
|
||||
func (b TruncateBuilder) truncate(name string) TruncateBuilder {
|
||||
return builder.Set(b, "TableName", name).(TruncateBuilder)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue