-
-
Notifications
You must be signed in to change notification settings - Fork 347
Closed
Description
Your Question
列表如何实现只查询软删除的数据
The document you expected this should be explained
recycle := param.Get("recycle")
if recycle == "all" {
// 查询所有产品,包括已删除的
conditions = conditions.Unscoped()
} else if recycle == "recycle" {
// 查询已删除的产品
conditions = conditions.Unscoped().
Where(q.DeleteTime.Neq(0))
// 错误:无法将 0 (类型 untyped int) 用作类型 driver.Valuer 类型未实现 driver.Valuer,因为缺少某些方法: Value() (Value, error)
}
type Product struct {
ID int32 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
Name string `gorm:"column:name;not null;comment:名称" json:"name"` // 名称
Image string `gorm:"column:image;not null;comment:产品首图" json:"image"` // 产品首图
......
CreateTime int32 `gorm:"column:create_time;not null;autoCreateTime;comment:记录时间" json:"create_time"` // 记录时间
UpdateTime int32 `gorm:"column:update_time;not null;autoUpdateTime;comment:更新时间" json:"update_time"` // 更新时间
DeleteTime soft_delete.DeletedAt `gorm:"column:delete_time;not null;comment:删除时间" json:"delete_time"` // 删除时间
Skus []ProductSku `gorm:"foreignKey:product_id;references:id" json:"skus"`
}
Expected answer
Metadata
Metadata
Assignees
Labels
No labels