MCPcopy
hub / github.com/go-gorm/gorm / Unscoped

Method Unscoped

chainable_api.go:455–459  ·  view source on GitHub ↗

Unscoped disables the global scope of soft deletion in a query. By default, GORM uses soft deletion, marking records as "deleted" by setting a timestamp on a specific field (e.g., `deleted_at`). Unscoped allows queries to include records marked as deleted, overriding the soft deletion behavior. Exam

()

Source from the content-addressed store, hash-verified

453// db.Unscoped().Find(&users)
454// // Retrieves all users, including deleted ones.
455func (db *DB) Unscoped() (tx *DB) {
456 tx = db.getInstance()
457 tx.Statement.Unscoped = true
458 return
459}
460
461func (db *DB) Raw(sql string, values ...interface{}) (tx *DB) {
462 tx = db.getInstance()

Callers 15

PreloadMethod · 0.45
DeleteBeforeAssociationsFunction · 0.45
TestPropagateUnscopedFunction · 0.45
TestPreloadWithCondsFunction · 0.45
TestChainableAPIFunction · 0.45
TestDeleteWithTableFunction · 0.45
TestSaveFunction · 0.45

Calls 1

getInstanceMethod · 0.95

Tested by 15

TestPropagateUnscopedFunction · 0.36
TestPreloadWithCondsFunction · 0.36
TestChainableAPIFunction · 0.36
TestDeleteWithTableFunction · 0.36
TestSaveFunction · 0.36
dbFunction · 0.36