我有一个发送参数的 APIcurrentList: ["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');