soft_delete

package module
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2021 License: MIT Imports: 5 Imported by: 0

README

Soft Delete

This plugin supports bool type for gorm soft delete plugin. The original library works only with int.

import "gorm.io/plugin/soft_delete"

type User struct {
  ID        uint
  Name      string
  DeletedAt soft_delete.IsDeleted
}

// Query
SELECT * FROM users WHERE is_deleted = FALSE;

// Delete
UPDATE users SET is_deleted = TRUE WHERE ID = 1;

Updates DeletedAt field

Plugin searches for tag DeletedAtField, it's value uses as the field name.

type User struct {
  ID        uint
  Name      string
  DeletedAt time.Time
  IsDel     soft_delete.DeletedAt `gorm:"DeletedAtField:DeletedAt"`
}

// Query
SELECT * FROM users WHERE is_del = FALSE;

// Delete
UPDATE users SET is_del = TRUE, deleted_at = /* current unix second */ WHERE ID = 1;

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IsDeleted

type IsDeleted bool

func (IsDeleted) DeleteClauses

func (IsDeleted) DeleteClauses(f *schema.Field) []clause.Interface

func (IsDeleted) QueryClauses

func (IsDeleted) QueryClauses(f *schema.Field) []clause.Interface

func (*IsDeleted) Scan

func (i *IsDeleted) Scan(value interface{}) error

func (IsDeleted) UpdateClauses

func (IsDeleted) UpdateClauses(f *schema.Field) []clause.Interface

type SoftDeleteDeleteClause

type SoftDeleteDeleteClause struct {
	Field         *schema.Field
	DeleteAtField *schema.Field
}

func (SoftDeleteDeleteClause) Build

func (SoftDeleteDeleteClause) MergeClause

func (sd SoftDeleteDeleteClause) MergeClause(*clause.Clause)

func (SoftDeleteDeleteClause) ModifyStatement

func (sd SoftDeleteDeleteClause) ModifyStatement(stmt *gorm.Statement)

func (SoftDeleteDeleteClause) Name

func (sd SoftDeleteDeleteClause) Name() string

type SoftDeleteQueryClause

type SoftDeleteQueryClause struct {
	Field *schema.Field
}

func (SoftDeleteQueryClause) Build

func (SoftDeleteQueryClause) MergeClause

func (sd SoftDeleteQueryClause) MergeClause(*clause.Clause)

func (SoftDeleteQueryClause) ModifyStatement

func (sd SoftDeleteQueryClause) ModifyStatement(stmt *gorm.Statement)

func (SoftDeleteQueryClause) Name

func (sd SoftDeleteQueryClause) Name() string

type SoftDeleteUpdateClause

type SoftDeleteUpdateClause struct {
	Field *schema.Field
}

func (SoftDeleteUpdateClause) Build

func (SoftDeleteUpdateClause) MergeClause

func (sd SoftDeleteUpdateClause) MergeClause(*clause.Clause)

func (SoftDeleteUpdateClause) ModifyStatement

func (sd SoftDeleteUpdateClause) ModifyStatement(stmt *gorm.Statement)

func (SoftDeleteUpdateClause) Name

func (sd SoftDeleteUpdateClause) Name() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL