代码拉取完成,页面将自动刷新
package orm
type TableReference interface {
table()
}
// 普通表
type Table struct {
entity any
alias string
}
func (t Table) As(alias string) Table {
return Table{
entity: t.entity,
alias: alias,
}
}
func (t Table) C(name string) Column {
return Column{
Name: name,
Table: t,
}
}
func (t Table) table() {}
func (t Table) Join(target TableReference) *JoinBuilder {
return &JoinBuilder{
left: t,
right: target,
typ: " JOIN ",
}
}
func (t Table) LeftJoin(target TableReference) *JoinBuilder {
return &JoinBuilder{
left: t,
right: target,
typ: " LEFT JOIN ",
}
}
func (t Table) RightJoin(target TableReference) *JoinBuilder {
return &JoinBuilder{
left: t,
right: target,
typ: " RIGHT JOIN ",
}
}
// join
type Join struct {
left TableReference
right TableReference
typ string
on []Predicate
}
func (j Join) table() {}
func (j Join) Join(target TableReference) *JoinBuilder {
return &JoinBuilder{
left: j,
right: target,
typ: " JOIN ",
}
}
func (j Join) LeftJoin(target TableReference) *JoinBuilder {
return &JoinBuilder{
left: j,
right: target,
typ: " LEFT JOIN ",
}
}
func (j Join) RightJoin(target TableReference) *JoinBuilder {
return &JoinBuilder{
left: j,
right: target,
typ: " RIGHT JOIN ",
}
}
// /=====================================
func TableOf(entity any) Table {
return Table{entity: entity}
}
type JoinBuilder struct {
left TableReference
right TableReference
typ string
}
func (j *JoinBuilder) On(ps ...Predicate) Join {
return Join{
left: j.left,
right: j.right,
typ: j.typ,
on: ps,
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。