【发布时间】:2018-04-06 14:59:17
【问题描述】:
我有一个 API,用于发送参数 currentList: ["hey", "cool"]
type sentenceCreateReq struct {
CurrentList []string `json:"currentList"`
}
func (usr *SentenceResource) Create(c buffalo.Context) error {
req := sentenceCreateReq{}
parseReqBody(c.Request(), &req)
...
sentence := models.Sentence{}
err := tx.Limit(1).Where("word NOT IN (?)", c.Params("currentList")).First(&sentence)
...
}
如何加入字符串数组以满足我的要求?
我要运行的SQL语句是
SELECT * FROM sentences WHERE word NOT IN ('hey', 'cool');
【问题讨论】: