github.com/friesencr/pop/v6@v6.1.6/clause.go (about) 1 package pop 2 3 import ( 4 "fmt" 5 "strings" 6 ) 7 8 type clause struct { 9 Fragment string 10 Arguments []interface{} 11 } 12 13 type clauses []clause 14 15 func (c clauses) Join(sep string) string { 16 out := make([]string, 0, len(c)) 17 for _, clause := range c { 18 out = append(out, clause.Fragment) 19 } 20 return strings.Join(out, sep) 21 } 22 23 func (c clauses) Args() (args []interface{}) { 24 for _, clause := range c { 25 args = append(args, clause.Arguments...) 26 } 27 return 28 } 29 30 type fromClause struct { 31 From string 32 As string 33 } 34 35 type fromClauses []fromClause 36 37 func (c fromClause) String() string { 38 return fmt.Sprintf("%s AS %s", c.From, c.As) 39 } 40 41 func (c fromClauses) String() string { 42 var cs []string 43 for _, cl := range c { 44 cs = append(cs, cl.String()) 45 } 46 return strings.Join(cs, ", ") 47 } 48 49 type belongsToThroughClause struct { 50 BelongsTo *Model 51 Through *Model 52 } 53 54 type belongsToThroughClauses []belongsToThroughClause