wp-go/app/pkg/models/relation/posts.go

20 lines
445 B
Go
Raw Normal View History

2023-05-21 13:30:00 +00:00
package relation
import (
"github.com/fthvgb1/wp-go/app/pkg/models"
"github.com/fthvgb1/wp-go/model"
)
2023-05-22 06:49:35 +00:00
var PostsWithAuthor = model.RelationHasOne(func(m *models.Posts) uint64 {
2023-05-21 13:30:00 +00:00
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",
})