github.com/RevenueMonster/sqlike@v1.0.6/sqlike/actions/delete.go (about)

     1  package actions
     2  
     3  import (
     4  	"github.com/RevenueMonster/sqlike/sql/expr"
     5  )
     6  
     7  // DeleteStatement :
     8  type DeleteStatement interface {
     9  	Where(fields ...interface{}) DeleteStatement
    10  	OrderBy(fields ...interface{}) DeleteStatement
    11  	Limit(num uint) DeleteStatement
    12  }
    13  
    14  // DeleteActions :
    15  type DeleteActions struct {
    16  	Database   string
    17  	Table      string
    18  	Conditions []interface{}
    19  	Sorts      []interface{}
    20  	Record     uint
    21  }
    22  
    23  // Where :
    24  func (act *DeleteActions) Where(fields ...interface{}) DeleteStatement {
    25  	act.Conditions = expr.And(fields...).Values
    26  	return act
    27  }
    28  
    29  // OrderBy :
    30  func (act *DeleteActions) OrderBy(fields ...interface{}) DeleteStatement {
    31  	act.Sorts = fields
    32  	return act
    33  }
    34  
    35  // Limit :
    36  func (act *DeleteActions) Limit(num uint) DeleteStatement {
    37  	if num > 0 {
    38  		act.Record = num
    39  	}
    40  	return act
    41  }