Code Explainers

Code explainers tagged #soft-delete

python
from datetime import datetime, timezone
 
from flask import abort
from sqlalchemy import Column, DateTime

Soft deletes with a custom SQLAlchemy Query in Flask

soft-delete mixin query-subclass
Advanced 7 steps
go
package middleware
 
import (
	"github.com/gin-gonic/gin"

Injecting a scoped GORM query via Gin middleware

middleware dependency-injection request-context
Intermediate 9 steps
php
<?php
 
namespace App\Models\Concerns;
 

Building soft deletes as an Eloquent trait in Laravel

traits soft-delete global-scope
Intermediate 10 steps
java
@Entity
@Table(name = "orders")
@SQLDelete(sql = "UPDATE orders SET deleted = true, deleted_at = now() WHERE id = ?")
@Where(clause = "deleted = false")

Soft deletes with Hibernate in Spring

soft-delete jpa hibernate
Intermediate 9 steps
python
from django.db import models
from django.utils import timezone
 
 

How soft deletes work in Django

soft-delete querysets managers
Intermediate 10 steps
ruby
module SoftDeletable
  extend ActiveSupport::Concern
 
  included do

How a soft-delete concern works in Rails

concerns soft-delete scopes
Intermediate 8 steps
ruby
class Article < ApplicationRecord
  belongs_to :author
 
  default_scope { where(deleted_at: nil) }

How scopes compose in Rails

scopes query-composition activerecord
Intermediate 9 steps