* Rename models to plural form for consistency * Change table names to include 'public' schema * Update timestamp types to SqlTimeStamp for consistency * Adjust relationships to use pluralized user models
71 lines
2.9 KiB
Go
71 lines
2.9 KiB
Go
// Code generated by relspecgo. DO NOT EDIT.
|
|
package models
|
|
|
|
import (
|
|
"fmt"
|
|
resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes"
|
|
"github.com/uptrace/bun"
|
|
)
|
|
|
|
type ModelPublicEventLogs struct {
|
|
bun.BaseModel `bun:"table:public.event_logs,alias:event_logs"`
|
|
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
|
|
Action resolvespec_common.SqlString `bun:"action,type:varchar(50),nullzero," json:"action"` // create
|
|
CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
|
|
Data resolvespec_common.SqlString `bun:"data,type:text,nullzero," json:"data"` // JSON encoded event data
|
|
EntityID resolvespec_common.SqlString `bun:"entity_id,type:varchar(36),nullzero," json:"entity_id"`
|
|
EntityType resolvespec_common.SqlString `bun:"entity_type,type:varchar(100),nullzero," json:"entity_type"` // user
|
|
Error resolvespec_common.SqlString `bun:"error,type:text,nullzero," json:"error"`
|
|
EventType resolvespec_common.SqlString `bun:"event_type,type:varchar(100),notnull," json:"event_type"`
|
|
IpAddress resolvespec_common.SqlString `bun:"ip_address,type:varchar(50),nullzero," json:"ip_address"`
|
|
Success bool `bun:"success,type:boolean,default:true,notnull," json:"success"`
|
|
UserAgent resolvespec_common.SqlString `bun:"user_agent,type:text,nullzero," json:"user_agent"`
|
|
UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),nullzero," json:"user_id"` // Optional user reference
|
|
RelUserID *ModelPublicUsers `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUsers
|
|
}
|
|
|
|
// TableName returns the table name for ModelPublicEventLogs
|
|
func (m ModelPublicEventLogs) TableName() string {
|
|
return "public.event_logs"
|
|
}
|
|
|
|
// TableNameOnly returns the table name without schema for ModelPublicEventLogs
|
|
func (m ModelPublicEventLogs) TableNameOnly() string {
|
|
return "event_logs"
|
|
}
|
|
|
|
// SchemaName returns the schema name for ModelPublicEventLogs
|
|
func (m ModelPublicEventLogs) SchemaName() string {
|
|
return "public"
|
|
}
|
|
|
|
// GetID returns the primary key value
|
|
func (m ModelPublicEventLogs) GetID() int64 {
|
|
return m.ID.Int64()
|
|
}
|
|
|
|
// GetIDStr returns the primary key as a string
|
|
func (m ModelPublicEventLogs) GetIDStr() string {
|
|
return fmt.Sprintf("%d", m.ID)
|
|
}
|
|
|
|
// SetID sets the primary key value
|
|
func (m ModelPublicEventLogs) SetID(newid int64) {
|
|
m.UpdateID(newid)
|
|
}
|
|
|
|
// UpdateID updates the primary key value
|
|
func (m *ModelPublicEventLogs) UpdateID(newid int64) {
|
|
m.ID.FromString(fmt.Sprintf("%d", newid))
|
|
}
|
|
|
|
// GetIDName returns the name of the primary key column
|
|
func (m ModelPublicEventLogs) GetIDName() string {
|
|
return "id"
|
|
}
|
|
|
|
// GetPrefix returns the table prefix
|
|
func (m ModelPublicEventLogs) GetPrefix() string {
|
|
return "ELV"
|
|
}
|