database

package
v0.0.0-...-6e86e58 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDatabaseConnection

func CreateDatabaseConnection(dbConfig DBConfig) (*bun.DB, error)

func CreateTables

func CreateTables(db *bun.DB)

Types

type DBConfig

type DBConfig struct {
	Host     string `json:"host" validate:"required"`
	Port     int    `json:"port"`
	Username string `json:"username" validate:"required"`
	Password string `json:"password" validate:"required"`
	SSLMode  string `json:"SSLMode" validate:"required"`
}

func (*DBConfig) AsDSN

func (d *DBConfig) AsDSN() string

type FileMetadataModel

type FileMetadataModel struct {
	bun.BaseModel `bun:"table:file_metadata"`
	TableID
	FormDataID         uuid.UUID `bun:"form_data_id,type:uuid,notnull"`
	OriginalFilename   string    `bun:"original_filename,type:varchar(256),notnull"`
	Path               string    `bun:"path,type:varchar(512),notnull"`
	MappingSchemaField int64     `bun:"mapping_schema_field,type:bigint,notnull"`
}

type FormDataModel

type FormDataModel struct {
	bun.BaseModel `bun:"table:form_data"`
	TableID
	UserID       uuid.UUID `bun:"user_id,type:uuid,notnull"`
	FormSchemaID uuid.UUID `bun:"form_schema_id,type:uuid,notnull"`
	Name         string    `bun:"name,type:varchar(64),notnull"`
	Data         []byte    `bun:"data,type:jsonb"`
}

type FormModel

type FormModel struct {
	bun.BaseModel `bun:"table:forms"`
	TableID
	UserID string `bun:"user_id,type:uuid"`
	Title  string `bun:"title,type:varchar(256),notnull"`
}

type FormSchemaModel

type FormSchemaModel struct {
	bun.BaseModel `bun:"table:form_schemas"`
	TableID
	FormID   uuid.UUID `bun:"form_id,type:uuid,notnull"`
	Title    string    `bun:"title,type:varchar(256),notnull"`
	Version  string    `bun:"version,type:varchar(64),notnull"`
	Schema   []byte    `bun:"schema,type:jsonb"`
	ReadOnly bool      `bun:"read_only,notnull,default:false"`
}

type TableID

type TableID struct {
	ID uuid.UUID `bun:"id,type:uuid,pk,default:uuid_generate_v4()"`
}

type UserModel

type UserModel struct {
	bun.BaseModel `bun:"table:users"`
	TableID
	Username string `bun:"username,type:varchar(128),notnull,unique"`
	Password string `bun:"password,type:varchar(60),notnull"`
}

Jump to

Keyboard shortcuts

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