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 ¶
RegisterModels registers all models with the provided bun database instance.
func SeedingMode ¶
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 ¶
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 ¶
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 ¶
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"`
}
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 ¶
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"`
}
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"`
}
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"`
}
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 ¶
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"`
}
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"`
}
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"`
}
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 ¶
Click to show internal directories.
Click to hide internal directories.