From d0b4ceb726f254599c250df2eb7ee9bb86d8a68a Mon Sep 17 00:00:00 2001 From: Ivan Chavez <64909655+AntonyChR@users.noreply.github.com> Date: Tue, 16 Apr 2024 22:38:55 -0500 Subject: [PATCH] Added comment describing Unscoped() method (#6969) --- chainable_api.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/chainable_api.go b/chainable_api.go index 1ec9b865..33370603 100644 --- a/chainable_api.go +++ b/chainable_api.go @@ -429,6 +429,15 @@ func (db *DB) Assign(attrs ...interface{}) (tx *DB) { return } +// 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. +// Example: +// var users []User +// db.Unscoped().Find(&users) +// // Retrieves all users, including deleted ones. func (db *DB) Unscoped() (tx *DB) { tx = db.getInstance() tx.Statement.Unscoped = true