Documentation
¶
Index ¶
- Constants
- type DatabaseType
- func (dt DatabaseType) GetBlobColumnType() string
- func (dt DatabaseType) GetIntegerColumnType() string
- func (dt DatabaseType) GetJSONColumnType() string
- func (dt DatabaseType) GetJSONExtractFunction(column, path string) string
- func (dt DatabaseType) GetJSONValidationConstraint(columnName string) string
- func (dt DatabaseType) GetMetadataIndexSQL(tableName, indexName, path string) string
- func (dt DatabaseType) GetTimestampColumnType() string
- func (dt DatabaseType) IsValid() bool
- func (dt DatabaseType) RequiresJSONValidation() bool
- func (dt DatabaseType) String() string
- func (dt DatabaseType) SupportsJSONIndexing() bool
- type MetadataColumn
- func (mc *MetadataColumn) Clear()
- func (mc *MetadataColumn) Delete(key string)
- func (mc *MetadataColumn) FromJSON(data []byte) error
- func (mc *MetadataColumn) Get(key string) (interface{}, bool)
- func (mc *MetadataColumn) GetInt(key string) (int, bool)
- func (mc *MetadataColumn) GetString(key string) (string, bool)
- func (mc *MetadataColumn) IsEmpty() bool
- func (mc *MetadataColumn) Keys() []string
- func (mc *MetadataColumn) Scan(value interface{}) error
- func (mc *MetadataColumn) Set(key string, value interface{})
- func (mc *MetadataColumn) ToJSON() ([]byte, error)
- func (mc MetadataColumn) Value() (driver.Value, error)
Constants ¶
const MigrationExample = `` /* 523-byte string literal not displayed */
Example migration SQL for adding metadata column to existing tables
const PostgreSQLExample = `` /* 1049-byte string literal not displayed */
PostgreSQL DDL example with JSONB support
const SQLiteExample = `` /* 1053-byte string literal not displayed */
SQLite DDL example with JSON support
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DatabaseType ¶
type DatabaseType string
DatabaseType represents supported database types
const ( PostgreSQL DatabaseType = "postgresql" SQLite DatabaseType = "sqlite" MySQL DatabaseType = "mysql" )
func ParseDatabaseType ¶
func ParseDatabaseType(s string) DatabaseType
ParseDatabaseType parses a string into a DatabaseType
func (DatabaseType) GetBlobColumnType ¶
func (dt DatabaseType) GetBlobColumnType() string
GetBlobColumnType returns the appropriate BLOB column type for each database
func (DatabaseType) GetIntegerColumnType ¶
func (dt DatabaseType) GetIntegerColumnType() string
GetIntegerColumnType returns the appropriate integer column type for each database
func (DatabaseType) GetJSONColumnType ¶
func (dt DatabaseType) GetJSONColumnType() string
GetJSONColumnType returns the appropriate JSON column type for each database
func (DatabaseType) GetJSONExtractFunction ¶
func (dt DatabaseType) GetJSONExtractFunction(column, path string) string
GetJSONExtractFunction returns the JSON extraction function for each database
func (DatabaseType) GetJSONValidationConstraint ¶
func (dt DatabaseType) GetJSONValidationConstraint(columnName string) string
GetJSONValidationConstraint returns the JSON validation constraint for databases that need it
func (DatabaseType) GetMetadataIndexSQL ¶
func (dt DatabaseType) GetMetadataIndexSQL(tableName, indexName, path string) string
GetMetadataIndexSQL returns the SQL for creating metadata indexes
func (DatabaseType) GetTimestampColumnType ¶
func (dt DatabaseType) GetTimestampColumnType() string
GetTimestampColumnType returns the appropriate timestamp column type for each database
func (DatabaseType) IsValid ¶
func (dt DatabaseType) IsValid() bool
IsValid checks if the database type is supported
func (DatabaseType) RequiresJSONValidation ¶
func (dt DatabaseType) RequiresJSONValidation() bool
RequiresJSONValidation returns true if the database requires JSON validation constraints
func (DatabaseType) String ¶
func (dt DatabaseType) String() string
String returns the string representation of the database type
func (DatabaseType) SupportsJSONIndexing ¶
func (dt DatabaseType) SupportsJSONIndexing() bool
SupportsJSONIndexing returns true if the database supports efficient JSON indexing
type MetadataColumn ¶
type MetadataColumn struct {
// contains filtered or unexported fields
}
MetadataColumn provides cross-database JSON column support It implements sql.Scanner and driver.Valuer for seamless database integration
func NewMetadataColumn ¶
func NewMetadataColumn() *MetadataColumn
NewMetadataColumn creates a new MetadataColumn instance
func (*MetadataColumn) Clear ¶
func (mc *MetadataColumn) Clear()
Clear removes all data from the metadata
func (*MetadataColumn) Delete ¶
func (mc *MetadataColumn) Delete(key string)
Delete removes a key from the metadata
func (*MetadataColumn) FromJSON ¶
func (mc *MetadataColumn) FromJSON(data []byte) error
FromJSON populates the metadata from JSON bytes
func (*MetadataColumn) Get ¶
func (mc *MetadataColumn) Get(key string) (interface{}, bool)
Get retrieves a value by key from the metadata
func (*MetadataColumn) GetInt ¶
func (mc *MetadataColumn) GetInt(key string) (int, bool)
GetInt retrieves an int value by key
func (*MetadataColumn) GetString ¶
func (mc *MetadataColumn) GetString(key string) (string, bool)
GetString retrieves a string value by key
func (*MetadataColumn) IsEmpty ¶
func (mc *MetadataColumn) IsEmpty() bool
IsEmpty returns true if the metadata contains no data
func (*MetadataColumn) Keys ¶
func (mc *MetadataColumn) Keys() []string
Keys returns all keys in the metadata
func (*MetadataColumn) Scan ¶
func (mc *MetadataColumn) Scan(value interface{}) error
Scan implements sql.Scanner for database/sql This handles reading JSON data from both PostgreSQL JSONB and SQLite TEXT columns
func (*MetadataColumn) Set ¶
func (mc *MetadataColumn) Set(key string, value interface{})
Set stores a key-value pair in the metadata
func (*MetadataColumn) ToJSON ¶
func (mc *MetadataColumn) ToJSON() ([]byte, error)
ToJSON returns the JSON representation of the metadata