Skip to content

Delete删除数据

Tuuz edited this page Jun 20, 2022 · 4 revisions

一般删除方法

func Api_delete_byToken(qq, token interface{}) bool {
    db := tuuz.Db().Table(table)
    where := map[string]interface{}{
        "qq":    qq,
        "token": token,
    }
    db.Where(where)
    _, err := db.Delete()
    if err != nil {
        Log.Dbrr(err, tuuz.FUNCTION_ALL())
        return false
    } else {
        return true
    }
}

事务删除

type Interface struct {
	Db gorose.IOrm
}


func (self *Interface) Api_delete(id interface{}) bool {
	db := self.Db.Table(Table)
	where := map[string]interface{}{
		"id": id,
	}
	db.Where(where)
	_, err := db.Delete()
	if err != nil {
		Log.Dbrr(err, tuuz.FUNCTION_ALL())
		return false
	} else {
		return true
	}
}