models

package
v0.0.0-...-2d8f2a6 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChatMemberPermissionOwner  int64 = 0b_0000_0001_0000_0011
	ChatMemberPermissionAdmin  int64 = 0b_0000_0001_0000_0010
	ChatMemberPermissionMember int64 = 0b_0000_0001_0000_0000
)
View Source
const (
	LoginProviderFormPassword = "FORM_PASSWORD"
	LoginProviderSmsOtpCode   = "SMS_OTP_CODE"
)
View Source
const (
	UserProfileDisplayNameAttribute = "profile.display_name"
	UserProfileAvatarURLAttribute   = "profile.avatar_url"
	UserProfileGenderAttribute      = "profile.gender"
)
View Source
const (
	RealmFlagsAllowRegistration int64 = 0b_0000_0001
)

Variables

View Source
var ErrImmutableModel = errors.New("model is immutable and cannot be updated or deleted")

ErrImmutableModel represents an error when attempting to modify an immutable model.

Functions

func RegisterModels

func RegisterModels(bdb bun.IDB) error

RegisterModels registers all models with the provided bun database instance.

func SeedingMode

func SeedingMode(_ context.Context) bool

SeedingMode checks if the application is running in seeding mode.

Types

type ChatMember

type ChatMember struct {
	bun.BaseModel `bun:"table:chat_members,alias:chat_member"`

	// Columns
	UserId      string         `bun:"user_id,pk"`
	SessionId   string         `bun:"session_id,pk"`
	CreatedAt   time.Time      `bun:"created_at"`
	UpdatedAt   sql.NullTime   `bun:"updated_at"`
	ReadCursor  sql.NullString `bun:"read_cursor"`
	Permission  int64          `bun:"permission"`
	DisplayName sql.NullString `bun:"display_name"`

	// Relations
	User    *User        `bun:"rel:belongs-to,join:user_id=id"`
	Profile *Profile     `bun:"rel:belongs-to,join:user_id=id"`
	Session *ChatSession `bun:"rel:belongs-to,join:session_id=id"`
}

func (*ChatMember) BeforeAppendModel

func (m *ChatMember) BeforeAppendModel(_ context.Context, query bun.Query) error

type ChatRecord

type ChatRecord struct {
	bun.BaseModel `bun:"table:chat_records,alias:chat_record"`

	// Columns
	Id        string            `bun:"id,pk"`
	SessionId string            `bun:"session_id"`
	CreatorId string            `bun:"creator_id"`
	CreatedAt time.Time         `bun:"created_at"`
	UpdatedAt sql.NullTime      `bun:"updated_at"`
	DeletedAt sql.NullTime      `bun:"deleted_at,nullzero,soft_delete"`
	Version   string            `bun:"version"`
	Headers   map[string]string `bun:"headers,json_use_number"`
	Content   json.RawMessage   `bun:"content,json_use_number"`

	// Relations
	Session *ChatSession `bun:"rel:belongs-to,join:session_id=id"`
	Creator *User        `bun:"rel:belongs-to,join:creator_id=id"`
}

func (*ChatRecord) BeforeAppendModel

func (m *ChatRecord) BeforeAppendModel(_ context.Context, query bun.Query) error

type ChatSession

type ChatSession struct {
	bun.BaseModel `bun:"table:chat_sessions,alias:chat_session"`

	// Columns
	Id           string         `bun:"id,pk"`
	Readonly     bool           `bun:"readonly"`
	CreatedAt    time.Time      `bun:"created_at"`
	UpdatedAt    sql.NullTime   `bun:"updated_at"`
	DeletedAt    sql.NullTime   `bun:"deleted_at,nullzero,soft_delete"`
	IconUrl      sql.NullString `bun:"icon_url"`
	Title        string         `bun:"title"`
	Introduction sql.NullString `bun:"introduction"`

	// Relations
	Records []*ChatRecord `bun:"rel:has-many,join:id=session_id"`
	Members []*ChatMember `bun:"rel:has-many,join:id=session_id"`
}

func (*ChatSession) BeforeAppendModel

func (m *ChatSession) BeforeAppendModel(_ context.Context, query bun.Query) error

type Client

type Client struct {
	bun.BaseModel `bun:"table:clients,alias:client"`

	// Columns
	Id          string         `bun:"id,pk"`
	Disabled    bool           `bun:"disabled"`
	Immutable   bool           `bun:"immutable"`
	CreatedAt   time.Time      `bun:"created_at"`
	UpdatedAt   sql.NullTime   `bun:"updated_at"`
	DeletedAt   sql.NullTime   `bun:"deleted_at,soft_delete,nullzero"`
	ExpiresAt   sql.NullTime   `bun:"expires_at"`
	SecretKey   string         `bun:"secret_key"`
	SecretCode  sql.NullString `bun:"secret_code"`
	Description sql.NullString `bun:"description"`
}

func (*Client) BeforeAppendModel

func (m *Client) BeforeAppendModel(ctx context.Context, query bun.Query) error

type ClientUser

type ClientUser struct {
	bun.BaseModel `bun:"table:client_users,alias:client_user"`

	// Columns
	ClientId  string       `bun:"client_id,pk"`
	UserId    string       `bun:"user_id,pk"`
	Immutable bool         `bun:"immutable"`
	CreatedAt time.Time    `bun:"created_at"`
	UpdatedAt sql.NullTime `bun:"updated_at"`
	DeletedAt sql.NullTime `bun:"deleted_at,soft_delete,nullzero"`
}

func (*ClientUser) BeforeAppendModel

func (m *ClientUser) BeforeAppendModel(ctx context.Context, query bun.Query) error

type Device

type Device struct {
	bun.BaseModel `bun:"table:devices,alias:device"`

	// Columns
	Id        string            `bun:"id,pk"`
	UserId    sql.NullString    `bun:"user_id"`
	ClientId  sql.NullString    `bun:"client_id"`
	CreatedAt time.Time         `bun:"created_at"`
	UpdatedAt sql.NullTime      `bun:"updated_at"`
	TraceCode string            `bun:"trace_code"`
	PushToken sql.NullString    `bun:"push_token"`
	Metadata  map[string]string `bun:"metadata,json_use_number"`
}

func (*Device) BeforeAppendModel

func (m *Device) BeforeAppendModel(_ context.Context, query bun.Query) error

type Login

type Login struct {
	bun.BaseModel `bun:"table:logins,alias:login"`

	// Columns
	Id         string            `bun:"id,pk"`
	RealmId    string            `bun:"realm_id"`
	UserId     string            `bun:"user_id"`
	Disabled   bool              `bun:"disabled"`
	Immutable  bool              `bun:"immutable"`
	CreatedAt  time.Time         `bun:"created_at"`
	UpdatedAt  sql.NullTime      `bun:"updated_at"`
	DeletedAt  sql.NullTime      `bun:"deleted_at,soft_delete,nullzero"`
	ExpiresAt  sql.NullTime      `bun:"expires_at"`
	Provider   string            `bun:"provider"`
	Identifier string            `bun:"identifier"`
	Credential sql.NullString    `bun:"credential"`
	Metadata   map[string]string `bun:"metadata,json_use_number"`

	// Relations
	Realm *Realm `bun:"rel:belongs-to,join:realm_id=id"`
	User  *User  `bun:"rel:belongs-to,join:user_id=id"`
}

func (*Login) BeforeAppendModel

func (m *Login) BeforeAppendModel(ctx context.Context, query bun.Query) error

type Profile

type Profile struct {
	bun.BaseModel `bun:"table:profiles,alias:profile"`

	// Columns
	Id           string         `bun:"id,pk"`
	CreatedAt    time.Time      `bun:"created_at"`
	UpdatedAt    sql.NullTime   `bun:"updated_at"`
	DisplayName  string         `bun:"display_name"`
	AvatarUrl    sql.NullString `bun:"avatar_url"`
	Gender       sql.NullString `bun:"gender"`
	Birthdate    sql.NullTime   `bun:"birthdate"`
	Introduction sql.NullString `bun:"introduction"`

	// Relations
	User *User `bun:"rel:belongs-to,join:id=id"`
}

func (*Profile) BeforeAppendModel

func (m *Profile) BeforeAppendModel(_ context.Context, query bun.Query) error

type Realm

type Realm struct {
	bun.BaseModel `bun:"table:realms,alias:realm"`

	// Columns
	Id          string         `bun:"id,pk"`
	Disabled    bool           `bun:"disabled"`
	Immutable   bool           `bun:"immutable"`
	CreatedAt   time.Time      `bun:"created_at"`
	UpdatedAt   sql.NullTime   `bun:"updated_at"`
	DeletedAt   sql.NullTime   `bun:"deleted_at,soft_delete,nullzero"`
	ExpiresAt   sql.NullTime   `bun:"expires_at"`
	Flags       int64          `bun:"flags"`
	Name        string         `bun:"name"`
	Title       string         `bun:"title"`
	Description sql.NullString `bun:"description"`
}

func (*Realm) AllowRegistration

func (m *Realm) AllowRegistration() bool

func (*Realm) BeforeAppendModel

func (m *Realm) BeforeAppendModel(ctx context.Context, query bun.Query) error

type Role

type Role struct {
	bun.BaseModel `bun:"table:roles,alias:role"`

	// Columns
	Id          string         `bun:"id,pk"`
	RealmId     string         `bun:"realm_id"`
	Disabled    bool           `bun:"disabled"`
	Immutable   bool           `bun:"immutable"`
	CreatedAt   time.Time      `bun:"created_at"`
	UpdatedAt   sql.NullTime   `bun:"updated_at"`
	DeletedAt   sql.NullTime   `bun:"deleted_at,soft_delete,nullzero"`
	Name        string         `bun:"name"`
	Description sql.NullString `bun:"description"`

	// Relations
	Realm *Realm `bun:"rel:belongs-to,join:realm_id=id"`
}

func (*Role) BeforeAppendModel

func (m *Role) BeforeAppendModel(ctx context.Context, query bun.Query) error

type RoleUser

type RoleUser struct {
	bun.BaseModel `bun:"table:role_users,alias:role_user"`

	// Columns
	RoleId    string       `bun:"role_id,pk"`
	UserId    string       `bun:"user_id,pk"`
	Immutable bool         `bun:"immutable"`
	CreatedAt time.Time    `bun:"created_at"`
	UpdatedAt sql.NullTime `bun:"updated_at"`
	DeletedAt sql.NullTime `bun:"deleted_at,soft_delete,nullzero"`

	// Relations
	Role *Role `bun:"rel:belongs-to,join:role_id=id"`
	User *User `bun:"rel:belongs-to,join:user_id=id"`
}

func (*RoleUser) BeforeAppendModel

func (m *RoleUser) BeforeAppendModel(ctx context.Context, query bun.Query) error

type User

type User struct {
	bun.BaseModel `bun:"table:users,alias:user"`

	// Columns
	Id             string            `bun:"id,pk"`
	RealmId        string            `bun:"realm_id"`
	CreatorId      sql.NullString    `bun:"creator_id"`
	Disabled       bool              `bun:"disabled"`
	Approved       bool              `bun:"approved"`
	Verified       bool              `bun:"verified"`
	Immutable      bool              `bun:"immutable"`
	CreatedAt      time.Time         `bun:"created_at"`
	UpdatedAt      sql.NullTime      `bun:"updated_at"`
	DeletedAt      sql.NullTime      `bun:"deleted_at,soft_delete,nullzero"`
	ExpiresAt      sql.NullTime      `bun:"expires_at"`
	FirstLoginTime sql.NullTime      `bun:"first_login_time"`
	LastActiveTime sql.NullTime      `bun:"last_active_time"`
	Flags          int64             `bun:"flags"`
	Attributes     map[string]string `bun:"attributes,json_use_number"`
	PhoneNumber    sql.NullString    `bun:"phone_number"`
	EmailAddress   sql.NullString    `bun:"email_address"`
	Description    sql.NullString    `bun:"description"`

	// Relations
	Realm   *Realm   `bun:"rel:belongs-to,join:realm_id=id"`
	Profile *Profile `bun:"rel:has-one,join:id=id"`
	Creator *User    `bun:"rel:belongs-to,join:creator_id=id"`
}

func (*User) BeforeAppendModel

func (m *User) BeforeAppendModel(ctx context.Context, query bun.Query) error

type UserDevice

type UserDevice struct {
	bun.BaseModel `bun:"table:user_devices,alias:user_device"`

	// Columns
	UserId    string       `bun:"user_id,pk"`
	DeviceId  string       `bun:"device_id,pk"`
	CreatedAt time.Time    `bun:"created_at"`
	UpdatedAt sql.NullTime `bun:"updated_at"`
	DeletedAt sql.NullTime `bun:"deleted_at,soft_delete,nullzero"`
}

func (*UserDevice) BeforeAppendModel

func (m *UserDevice) BeforeAppendModel(_ context.Context, query bun.Query) error

Jump to

Keyboard shortcuts

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