Gorm: Search register including soft-deleted

Created on 15 Jun 2017  路  1Comment  路  Source: go-gorm/gorm

Hi, I have a table with some soft-deleted rows, now I need to ble able to search by ID but including that registers, how can I do it? everything that I tried ignores that rows because they don't have _DeletedAt = null_

Most helpful comment

Hi, this is documented over the CRUD Delete - http://jinzhu.me/gorm/crud.html#delete

Specifically,

// Find soft deleted records with Unscoped
db.Unscoped().Where("age = 20").Find(&users)
//// SELECT * FROM users WHERE age = 20;

Hope this helps.

>All comments

Hi, this is documented over the CRUD Delete - http://jinzhu.me/gorm/crud.html#delete

Specifically,

// Find soft deleted records with Unscoped
db.Unscoped().Where("age = 20").Find(&users)
//// SELECT * FROM users WHERE age = 20;

Hope this helps.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kumarsiva07 picture kumarsiva07  路  3Comments

sredxny picture sredxny  路  3Comments

easonlin404 picture easonlin404  路  3Comments

Quentin-M picture Quentin-M  路  3Comments

superwf picture superwf  路  3Comments