* 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
75 lines
3.3 KiB
Go
75 lines
3.3 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 ModelPublicHooks struct {
|
|
bun.BaseModel `bun:"table:public.hooks,alias:hooks"`
|
|
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
|
|
Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"`
|
|
AllowInsecure bool `bun:"allow_insecure,type:boolean,default:false,notnull," json:"allow_insecure"` // Skip TLS certificate verification
|
|
CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
|
|
DeletedAt resolvespec_common.SqlTimeStamp `bun:"deleted_at,type:timestamp,nullzero," json:"deleted_at"`
|
|
Description resolvespec_common.SqlString `bun:"description,type:text,nullzero," json:"description"`
|
|
Events resolvespec_common.SqlString `bun:"events,type:text,nullzero," json:"events"` // JSON array of event types
|
|
Headers resolvespec_common.SqlString `bun:"headers,type:text,nullzero," json:"headers"` // JSON encoded headers
|
|
Method resolvespec_common.SqlString `bun:"method,type:varchar(10),default:'POST',notnull," json:"method"` // HTTP method
|
|
Name resolvespec_common.SqlString `bun:"name,type:varchar(255),notnull," json:"name"`
|
|
RetryCount resolvespec_common.SqlInt32 `bun:"retry_count,type:int,default:3,notnull," json:"retry_count"`
|
|
Secret resolvespec_common.SqlString `bun:"secret,type:varchar(255),nullzero," json:"secret"` // HMAC signature secret
|
|
Timeout resolvespec_common.SqlInt32 `bun:"timeout,type:int,default:30,notnull," json:"timeout"` // Timeout in seconds
|
|
UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"`
|
|
URL resolvespec_common.SqlString `bun:"url,type:text,notnull," json:"url"`
|
|
UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),notnull," json:"user_id"`
|
|
RelUserID *ModelPublicUsers `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUsers
|
|
}
|
|
|
|
// TableName returns the table name for ModelPublicHooks
|
|
func (m ModelPublicHooks) TableName() string {
|
|
return "public.hooks"
|
|
}
|
|
|
|
// TableNameOnly returns the table name without schema for ModelPublicHooks
|
|
func (m ModelPublicHooks) TableNameOnly() string {
|
|
return "hooks"
|
|
}
|
|
|
|
// SchemaName returns the schema name for ModelPublicHooks
|
|
func (m ModelPublicHooks) SchemaName() string {
|
|
return "public"
|
|
}
|
|
|
|
// GetID returns the primary key value
|
|
func (m ModelPublicHooks) GetID() int64 {
|
|
return m.ID.Int64()
|
|
}
|
|
|
|
// GetIDStr returns the primary key as a string
|
|
func (m ModelPublicHooks) GetIDStr() string {
|
|
return fmt.Sprintf("%d", m.ID)
|
|
}
|
|
|
|
// SetID sets the primary key value
|
|
func (m ModelPublicHooks) SetID(newid int64) {
|
|
m.UpdateID(newid)
|
|
}
|
|
|
|
// UpdateID updates the primary key value
|
|
func (m *ModelPublicHooks) UpdateID(newid int64) {
|
|
m.ID.FromString(fmt.Sprintf("%d", newid))
|
|
}
|
|
|
|
// GetIDName returns the name of the primary key column
|
|
func (m ModelPublicHooks) GetIDName() string {
|
|
return "id"
|
|
}
|
|
|
|
// GetPrefix returns the table prefix
|
|
func (m ModelPublicHooks) GetPrefix() string {
|
|
return "HOO"
|
|
}
|