Update quick-start example with updated auto generated files
This commit is contained in:
parent
b375733dfa
commit
d63e56f574
8 changed files with 104 additions and 80 deletions
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/go-jet/jet/v2/postgres"
|
||||
)
|
||||
|
||||
var ActorInfo = newActorInfoTable()
|
||||
var ActorInfo = newActorInfoTable("dvds", "actor_info", "")
|
||||
|
||||
type actorInfoTable struct {
|
||||
postgres.Table
|
||||
|
|
@ -33,20 +33,23 @@ type ActorInfoTable struct {
|
|||
}
|
||||
|
||||
// AS creates new ActorInfoTable with assigned alias
|
||||
func (a *ActorInfoTable) AS(alias string) *ActorInfoTable {
|
||||
aliasTable := newActorInfoTable()
|
||||
aliasTable.Table.AS(alias)
|
||||
return aliasTable
|
||||
func (a ActorInfoTable) AS(alias string) *ActorInfoTable {
|
||||
return newActorInfoTable(a.SchemaName(), a.TableName(), alias)
|
||||
}
|
||||
|
||||
func newActorInfoTable() *ActorInfoTable {
|
||||
// Schema creates new ActorInfoTable with assigned schema name
|
||||
func (a ActorInfoTable) FromSchema(schemaName string) *ActorInfoTable {
|
||||
return newActorInfoTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
func newActorInfoTable(schemaName, tableName, alias string) *ActorInfoTable {
|
||||
return &ActorInfoTable{
|
||||
actorInfoTable: newActorInfoTableImpl("dvds", "actor_info"),
|
||||
EXCLUDED: newActorInfoTableImpl("", "excluded"),
|
||||
actorInfoTable: newActorInfoTableImpl(schemaName, tableName, alias),
|
||||
EXCLUDED: newActorInfoTableImpl("", "excluded", ""),
|
||||
}
|
||||
}
|
||||
|
||||
func newActorInfoTableImpl(schemaName, tableName string) actorInfoTable {
|
||||
func newActorInfoTableImpl(schemaName, tableName, alias string) actorInfoTable {
|
||||
var (
|
||||
ActorIDColumn = postgres.IntegerColumn("actor_id")
|
||||
FirstNameColumn = postgres.StringColumn("first_name")
|
||||
|
|
@ -57,7 +60,7 @@ func newActorInfoTableImpl(schemaName, tableName string) actorInfoTable {
|
|||
)
|
||||
|
||||
return actorInfoTable{
|
||||
Table: postgres.NewTable(schemaName, tableName, allColumns...),
|
||||
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||
|
||||
//Columns
|
||||
ActorID: ActorIDColumn,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/go-jet/jet/v2/postgres"
|
||||
)
|
||||
|
||||
var CustomerList = newCustomerListTable()
|
||||
var CustomerList = newCustomerListTable("dvds", "customer_list", "")
|
||||
|
||||
type customerListTable struct {
|
||||
postgres.Table
|
||||
|
|
@ -38,20 +38,23 @@ type CustomerListTable struct {
|
|||
}
|
||||
|
||||
// AS creates new CustomerListTable with assigned alias
|
||||
func (a *CustomerListTable) AS(alias string) *CustomerListTable {
|
||||
aliasTable := newCustomerListTable()
|
||||
aliasTable.Table.AS(alias)
|
||||
return aliasTable
|
||||
func (a CustomerListTable) AS(alias string) *CustomerListTable {
|
||||
return newCustomerListTable(a.SchemaName(), a.TableName(), alias)
|
||||
}
|
||||
|
||||
func newCustomerListTable() *CustomerListTable {
|
||||
// Schema creates new CustomerListTable with assigned schema name
|
||||
func (a CustomerListTable) FromSchema(schemaName string) *CustomerListTable {
|
||||
return newCustomerListTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
func newCustomerListTable(schemaName, tableName, alias string) *CustomerListTable {
|
||||
return &CustomerListTable{
|
||||
customerListTable: newCustomerListTableImpl("dvds", "customer_list"),
|
||||
EXCLUDED: newCustomerListTableImpl("", "excluded"),
|
||||
customerListTable: newCustomerListTableImpl(schemaName, tableName, alias),
|
||||
EXCLUDED: newCustomerListTableImpl("", "excluded", ""),
|
||||
}
|
||||
}
|
||||
|
||||
func newCustomerListTableImpl(schemaName, tableName string) customerListTable {
|
||||
func newCustomerListTableImpl(schemaName, tableName, alias string) customerListTable {
|
||||
var (
|
||||
IDColumn = postgres.IntegerColumn("id")
|
||||
NameColumn = postgres.StringColumn("name")
|
||||
|
|
@ -67,7 +70,7 @@ func newCustomerListTableImpl(schemaName, tableName string) customerListTable {
|
|||
)
|
||||
|
||||
return customerListTable{
|
||||
Table: postgres.NewTable(schemaName, tableName, allColumns...),
|
||||
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||
|
||||
//Columns
|
||||
ID: IDColumn,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue