sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

help: 帮忙看看 这种如何用呢

Open bytegolang opened this issue 3 years ago • 3 comments

比如:下面的gorm 转换sqlc如何做

if len(roleApis) > 0 {

		db := db.Orm.Debug().Model(&models.Api{}).
			Select("system_api.id").
			Joins("left join system_menu_api on system_menu_api.api = system_api.id")

		for _, p := range roleApis {
			db = db.Or("system_api.url = ? and system_api.method = ?", p[1], p[2])
		}
		err = db.Where("system_menu_api.menu = ?", menuId).Pluck("system_api.id", &apis).Error
		if err != nil {
			response.Error(c, err, response.GetApiError)
			return
		}
	}

bytegolang avatar May 06 '22 05:05 bytegolang

发一个简单的完整 Raw SQL 出来看看

yiplee avatar May 06 '22 09:05 yiplee

之前只考虑了 AND 串联,需要的话可以实现一个 OR 方法

yiplee avatar May 06 '22 09:05 yiplee

之前只考虑了 AND 串联,需要的话可以实现一个 OR 方法

or 的使用场景还是有的

bytegolang avatar May 07 '22 01:05 bytegolang