mixins

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SoftDeleteScope = &builder.Scope{
	Name: "soft-deletes",
	Query: func(b *builder.Builder) *builder.Builder {
		return b.Where(b.GetTable()+".deleted_at", "=", nil)
	},
	Delete: func(next func(q *builder.Builder, tx database.DB) error) func(q *builder.Builder, tx database.DB) error {
		return func(q *builder.Builder, tx database.DB) error {
			return q.Update(tx, builder.Updates{
				"deleted_at": time.Now(),
			})
		}
	},
}

Functions

This section is empty.

Types

type SoftDelete

type SoftDelete struct {
	DeletedAt *time.Time `json:"deleted_at" db:"deleted_at"`
}

func (*SoftDelete) Scopes

func (f *SoftDelete) Scopes() []*builder.Scope

type Timestamps

type Timestamps struct {
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}

func (*Timestamps) BeforeSave

func (t *Timestamps) BeforeSave(ctx context.Context, tx database.DB) error

BeforeSave implements hooks.BeforeSaver.

Jump to

Keyboard shortcuts

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