No more GORM.
Too much magic. I'll just write a JOIN and create small, composable data types to represent my domain objects. grug brain smile, complexity demon no visit todaymain
parent
4fec3f685b
commit
d9671822b7
@ -1,27 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Area struct {
|
||||
gorm.Model
|
||||
Uid string
|
||||
Name, Flags string
|
||||
Uid, Name, Flags, Color, Texture sql.NullString
|
||||
}
|
||||
|
||||
type Room struct {
|
||||
gorm.Model
|
||||
Uid string
|
||||
Name, Area string
|
||||
Building string
|
||||
Info, Notes, Flags string
|
||||
X, Y, Z int
|
||||
Norecall, Noportal int
|
||||
Exits []Exit `gorm:"foreignKey:Fromuid"`
|
||||
Uid, Name, Building, Info, Notes, Flags sql.NullString
|
||||
Area Area
|
||||
AreaName sql.NullString
|
||||
Norecall, Noportal sql.NullInt64
|
||||
Exits []Exit
|
||||
}
|
||||
|
||||
type Exit struct {
|
||||
gorm.Model
|
||||
Dir, Fromuid, Touid, Level string
|
||||
Dir sql.NullString
|
||||
Fromuid, Touid sql.NullString
|
||||
Level int
|
||||
}
|
||||
|
||||
type RoomExit struct {
|
||||
Room
|
||||
Exit
|
||||
}
|
||||
|
||||
func (re RoomExit) String() string {
|
||||
|
||||
return fmt.Sprintf("[%s(%s) |%s> %s]", re.Name.String, re.Uid.String, re.Dir.String, re.Touid.String)
|
||||
}
|
||||
|
Loading…
Reference in New Issue