add setup insert methods
This commit is contained in:
@@ -43,48 +43,52 @@ type World struct {
|
||||
// Flags any `json:"flags"`
|
||||
}
|
||||
|
||||
func (w *World) ToDB(dest *db.World) bool {
|
||||
func (w *World) ToDB(dest **db.World) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.ID = w.ID
|
||||
dest.Title = w.Title
|
||||
dest.Description = w.Description
|
||||
dest.Version = w.Version
|
||||
dest.Socket = w.Socket
|
||||
dest.Protected = w.Protected
|
||||
dest.Exclusive = w.Exclusive
|
||||
dest.PersistentStorage = w.PersistentStorage
|
||||
dest.System = w.System
|
||||
dest.Background = w.Background
|
||||
dest.JoinTheme = w.JoinTheme
|
||||
dest.CoreVersion = w.CoreVersion
|
||||
dest.SystemVersion = w.SystemVersion
|
||||
dest.LastPlayed = w.LastPlayed
|
||||
dest.Playtime = w.Playtime
|
||||
dest.NextSession = w.NextSession
|
||||
dest.Availability = w.Availability
|
||||
dest.Locked = w.Locked
|
||||
dest.Owned = w.Owned
|
||||
dest.HasStorage = w.HasStorage
|
||||
world := &db.World{
|
||||
ID: w.ID,
|
||||
Title: w.Title,
|
||||
Description: w.Description,
|
||||
Version: w.Version,
|
||||
Socket: w.Socket,
|
||||
Protected: w.Protected,
|
||||
Exclusive: w.Exclusive,
|
||||
PersistentStorage: w.PersistentStorage,
|
||||
System: w.System,
|
||||
Background: w.Background,
|
||||
JoinTheme: w.JoinTheme,
|
||||
CoreVersion: w.CoreVersion,
|
||||
SystemVersion: w.SystemVersion,
|
||||
LastPlayed: w.LastPlayed,
|
||||
Playtime: w.Playtime,
|
||||
NextSession: w.NextSession,
|
||||
Availability: w.Availability,
|
||||
Locked: w.Locked,
|
||||
Owned: w.Owned,
|
||||
HasStorage: w.HasStorage,
|
||||
}
|
||||
|
||||
copy(dest.Scripts, w.Scripts)
|
||||
copy(dest.Esmodules, w.Esmodules)
|
||||
copy(dest.Tags, w.Tags)
|
||||
copy(world.Scripts, w.Scripts)
|
||||
copy(world.Esmodules, w.Esmodules)
|
||||
copy(world.Tags, w.Tags)
|
||||
|
||||
w.Compatibility.ToDB(&dest.Compatibility)
|
||||
w.Relationships.ToDB(&dest.Relationships)
|
||||
w.Compatibility.ToDB(&world.Compatibility)
|
||||
w.Relationships.ToDB(&world.Relationships)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
go CopySliceToDBParallel(&wg, &dest.Authors, w.Authors)
|
||||
go CopySliceToDBParallel(&wg, &dest.Media, w.Media)
|
||||
go CopySliceToDBParallel(&wg, &dest.Styles, w.Styles)
|
||||
go CopySliceToDBParallel(&wg, &dest.Languages, w.Languages)
|
||||
go CopySliceToDBParallel(&wg, &dest.Packs, w.Packs)
|
||||
go CopySliceToDBParallel(&wg, &dest.PackFolders, w.PackFolders)
|
||||
go CopySliceToDBParallel(&wg, &world.Authors, w.Authors)
|
||||
go CopySliceToDBParallel(&wg, &world.Media, w.Media)
|
||||
go CopySliceToDBParallel(&wg, &world.Styles, w.Styles)
|
||||
go CopySliceToDBParallel(&wg, &world.Languages, w.Languages)
|
||||
go CopySliceToDBParallel(&wg, &world.Packs, w.Packs)
|
||||
go CopySliceToDBParallel(&wg, &world.PackFolders, w.PackFolders)
|
||||
wg.Wait()
|
||||
|
||||
*dest = world
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user