Your Question
How can I clean | delete all scopes?
The document you expected this should be explained
I have a particular rule for my project when I have to create a default Scope in db initialization, this is for set TenantId and soft delete resources.
...
//here I set default scope for any repository using gorm
conn = conn.Scopes(IgnoreDeleted, WithTenant)
...
//here I have a specific query when ai can clear all scopes
GetAllItensSkipTenant(db ) {
...
I need clean all scopes here for create a new query
ex: db.CleanScopes().First(&Items)
...
}
Expected answer
How I can clean scpes.
Comment From: solumna
Does using Unscoped() fit your use case?
db.Unscoped().First(&Items)
It doesn't explicitly said in the documentation but it should undo the scopes https://gorm.io/docs/delete.html#Find-soft-deleted-records
Comment From: firminoeducbank
Hi @solumna thanks for the answer.
But Unscoped doesn't work
Comment From: jinzhu
db.Session(&gorm.Session{NewDB:true})