2

Golang uses the Gorm framework for batch deletion. How to write this statement?

func DeleteUsers(id []int64) error {
    return db.Table("users").Delete(id).Error
}

After using the above method, all the data in the table will be cleared.

0

1 Answer 1

0

You can update the code as below to solve the issue.

func DeleteUsers(id []int64) error {
    return db.Table("users").Where("users.id", id).Delete(struct{}{}).Error
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.