base

package
v0.0.0-...-22e3136 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package base provides base model definitions and common database operations Author: Done-0 Created: 2025-09-25

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	ID        int64   `gorm:"primaryKey;type:bigint" json:"id"`          // Primary key (snowflake)
	CreatedAt int64   `gorm:"type:bigint" json:"created_at"`             // Creation timestamp
	UpdatedAt int64   `gorm:"type:bigint" json:"updated_at"`             // Update timestamp
	Ext       JSONMap `gorm:"type:json" json:"ext"`                      // Extension fields
	Deleted   bool    `gorm:"type:boolean;default:false" json:"deleted"` // Soft delete flag
}

Base contains common model fields

func (*Base) BeforeCreate

func (m *Base) BeforeCreate(db *gorm.DB) error

BeforeCreate implements GORM hook

func (*Base) BeforeUpdate

func (m *Base) BeforeUpdate(db *gorm.DB) error

BeforeUpdate implements GORM hook

type JSONMap

type JSONMap map[string]any

JSONMap handles JSON type fields

func (*JSONMap) Scan

func (j *JSONMap) Scan(value any) error

Scan implements sql.Scanner interface

func (JSONMap) Value

func (j JSONMap) Value() (driver.Value, error)

Value implements driver.Valuer interface

Jump to

Keyboard shortcuts

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