github.com/Ali-iotechsys/sqlboiler/v4@v4.0.0-20221208124957-6aec9a5f1f71/templates/main/13_all.go.tpl (about) 1 {{- $alias := .Aliases.Table .Table.Name}} 2 {{- $schemaTable := .Table.Name | .SchemaTable}} 3 {{- $tableName := .Table.Name }} 4 {{- $canSoftDelete := .Table.CanSoftDelete $.AutoColumns.Deleted }} 5 // {{$alias.UpPlural}} retrieves all the records using an executor. 6 func {{$alias.UpPlural}}(mods ...qm.QueryMod) {{$alias.DownSingular}}Query { 7 {{if and .AddSoftDeletes $canSoftDelete -}} 8 mods = append(mods, qm.From("{{$schemaTable}}"), qmhelper.WhereIsNull("{{$schemaTable}}.{{or $.AutoColumns.Deleted "deleted_at" | $.Quotes}}")) 9 {{else -}} 10 mods = append(mods, qm.From("{{$schemaTable}}")) 11 {{end -}} 12 13 q := NewQuery(mods...) 14 if len(queries.GetSelect(q)) == 0 { 15 queries.SetSelect(q, []string{"{{$schemaTable}}.*"}) 16 } 17 18 return {{$alias.DownSingular}}Query{q} 19 } 20 21 // {{$alias.UpPlural}}WithSchema retrieves all the records using an executor. 22 func {{$alias.UpPlural}}WithSchema(schema string, mods ...qm.QueryMod) {{$alias.DownSingular}}Query { 23 schemaTable := fmt.Sprintf("%s.{{$tableName}}", schema) 24 {{if and .AddSoftDeletes $canSoftDelete -}} 25 softDelStr := "{{or $.AutoColumns.Deleted "deleted_at" | $.Quotes}}" 26 mods = append(mods, qm.From(schemaTable), qmhelper.WhereIsNull(fmt.Sprintf("%s.%s", schemaTable, softDelStr))) 27 {{else -}} 28 mods = append(mods, qm.From(schemaTable)) 29 {{end -}} 30 31 q := NewQuery(mods...) 32 if len(queries.GetSelect(q)) == 0 { 33 allSel := fmt.Sprintf("%s.*", schemaTable) 34 queries.SetSelect(q, []string{allSel}) 35 } 36 37 return {{$alias.DownSingular}}Query{q} 38 }