wp-go/app/pkg/models/relation/posts.go
2023-05-21 21:30:00 +08:00

24 lines
547 B
Go

package relation
import (
"github.com/fthvgb1/wp-go/app/pkg/models"
"github.com/fthvgb1/wp-go/model"
)
var hasUser = model.RelationHasOne(func(m *models.Posts) uint64 {
return m.PostAuthor
}, func(p *models.Users) uint64 {
return p.Id
}, func(m *models.Posts, p *models.Users) {
m.Author = p
}, model.Relationship{
RelationType: model.HasOne,
Table: "wp_users user",
ForeignKey: "ID",
Local: "post_author",
})
func PostsWithAuthor() (func(any) []any, func(any, any), any, any, model.Relationship) {
return hasUser()
}