github.com/sharovik/devbot@v1.0.1-0.20240308094637-4a0387c40516/internal/dto/databasedto/base.go (about) 1 package databasedto 2 3 import "github.com/sharovik/orm/dto" 4 5 // New generates the model object for selected model interface 6 func New(table string, fields []interface{}, primary dto.ModelField, modelStruct dto.ModelInterface) dto.ModelInterface { 7 model := modelStruct 8 model.SetTableName(table) 9 model.SetPrimaryKey(primary) 10 for _, field := range fields { 11 switch f := field.(type) { 12 case dto.ModelField: 13 model.AddModelField(f) 14 } 15 } 16 17 return model 18 }