modelcollections

package
v0.0.0-...-cbe41fb Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPbCollectionMetadata

func NewPbCollectionMetadata(mc *ModelCollection) *apppb.CollectionMetadata

func NewPbSchemaFields

func NewPbSchemaFields(m ModelSchema) []*apppb.SchemaField

Types

type CollectionID

type CollectionID uuid.UUID

func NewCollectionID

func NewCollectionID() CollectionID

func Parse

func Parse(s string) (CollectionID, error)

func (*CollectionID) Scan

func (c *CollectionID) Scan(value interface{}) error

func (CollectionID) String

func (c CollectionID) String() string

func (CollectionID) Value

func (c CollectionID) Value() (driver.Value, error)

type FieldID

type FieldID int

func (FieldID) String

func (f FieldID) String() string

type ModelCollection

type ModelCollection struct {
	ID CollectionID `gorm:"column:id;primarykey;type:string;"`

	Type ModelCollectionType `gorm:"column:type;type:int;"`
	// Summary is a summary for the collections
	Summary   string         `gorm:"column:summary"`
	CreatedAt time.Time      `gorm:"column:created_at"`
	UpdatedAt time.Time      `gorm:"column:updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at"`

	Schemas        []ModelSchema           `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"` // associated to many schemes
	ModelProjectID modelprojects.ProjectID // foreign key to model project
	ModelProject   modelprojects.ModelProject
}

func NewModelCollection

func NewModelCollection(
	projectId modelprojects.ProjectID,
	id CollectionID,
	t apppb.CollectionType,
	summary string,
	schemas []ModelSchema,
) ModelCollection

func (ModelCollection) TableName

func (m ModelCollection) TableName() string

type ModelCollectionType

type ModelCollectionType apppb.CollectionType

func (ModelCollectionType) Number

func (m ModelCollectionType) Number() int

func (ModelCollectionType) Proto

func (*ModelCollectionType) Scan

func (m *ModelCollectionType) Scan(in any) error

func (ModelCollectionType) Value

func (m ModelCollectionType) Value() (driver.Value, error)

type ModelFieldSchema

type ModelFieldSchema struct {
	ID        FieldID        `gorm:"column:id;primarykey;type:int;autoIncrement"`
	CreatedAt time.Time      `gorm:"column:created_at"`
	UpdatedAt time.Time      `gorm:"column:updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at"`

	FieldName      string         `gorm:"column:field_name"` // dot concated path, a.b.c represents a -> b -> c path
	FieldValueType SwagValueType  `gorm:"column:value_type"`
	FieldExample   SwagValueValue `gorm:"column:value_example;type:jsonb"`

	ModelSchemaID SchemaID // foreign key to ModelSchema -> ID
}

func (ModelFieldSchema) TableName

func (m ModelFieldSchema) TableName() string

type ModelFieldsSchema

type ModelFieldsSchema []ModelFieldSchema

func (ModelFieldsSchema) ToJSON

func (m ModelFieldsSchema) ToJSON(dotPrefixs ...string) ([]byte, error)

type ModelSchema

type ModelSchema struct {
	ID        SchemaID       `gorm:"column:id;primarykey;type:int;uniqueIndex:cidsid;autoIncrement"`
	CreatedAt time.Time      `gorm:"column:created_at"`
	UpdatedAt time.Time      `gorm:"column:updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at"`

	Fields            []ModelFieldSchema `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	ModelCollectionID CollectionID       // foreigh key to ModelCollection -> ID
}

func NewModelSchema

func NewModelSchema(reqSchemas []*apppb.SchemaField) (ModelSchema, error)

func (ModelSchema) TableName

func (m ModelSchema) TableName() string

type SchemaID

type SchemaID int

func (SchemaID) String

func (s SchemaID) String() string

type SwagValueType

type SwagValueType string
var (
	NoneSwagValueType    SwagValueType = "none"
	StringSwagValueType  SwagValueType = "string"
	NumberSwagValueType  SwagValueType = "number"
	IntegerSwagValueType SwagValueType = "integer"
	BoolSwagValueType    SwagValueType = "bool"
)

func NewSwaggerValueType

func NewSwaggerValueType(pbDataType apppb.SchemaFieldDataType) SwagValueType

func (SwagValueType) Proto

type SwagValueValue

type SwagValueValue struct {
	StringValue  *string  `json:"str,omitempty"`
	NumberValue  *float64 `json:"num,omitempty"`
	IntegerValue *int64   `json:"int,omitempty"`
	BoolValue    *bool    `json:"bool,omitempty"`
}

func Must

func NewSwagValue

func NewSwagValue(v any) (SwagValueValue, error)

func (SwagValueValue) Proto

func (*SwagValueValue) Scan

func (s *SwagValueValue) Scan(in any) error

func (SwagValueValue) Type

func (s SwagValueValue) Type() SwagValueType

func (SwagValueValue) Value

func (s SwagValueValue) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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