Documentation
¶
Index ¶
- func BuildCondition(where any) types.Condition
- type Client
- type ClientOption
- type Model
- func (m *Model) Aggregate(jsonQuery string) (map[string]any, error)
- func (m *Model) Count(jsonQuery string) (int64, error)
- func (m *Model) Create(jsonData string) (map[string]any, error)
- func (m *Model) CreateTyped(jsonData string, dest any) error
- func (m *Model) Delete(jsonQuery string) (map[string]any, error)
- func (m *Model) DeleteMany(jsonQuery string) (map[string]any, error)
- func (m *Model) FindFirst(jsonQuery string) (map[string]any, error)
- func (m *Model) FindFirstTyped(jsonQuery string, dest any) error
- func (m *Model) FindMany(jsonQuery string) ([]map[string]any, error)
- func (m *Model) FindManyTyped(jsonQuery string, dest any) error
- func (m *Model) FindUnique(jsonQuery string) (map[string]any, error)
- func (m *Model) FindUniqueTyped(jsonQuery string, dest any) error
- func (m *Model) GroupBy(jsonQuery string) ([]map[string]any, error)
- func (m *Model) Query(jsonQuery string) (any, error)
- func (m *Model) QueryTyped(jsonQuery string, dest any) error
- func (m *Model) Raw(sql string, args ...any) *RawQuery
- func (m *Model) Update(jsonQuery string) (map[string]any, error)
- func (m *Model) UpdateMany(jsonQuery string) (map[string]any, error)
- type OrmConformanceTests
- type OrmDriverCharacteristics
- type RawQuery
- type TypeConverter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildCondition ¶
BuildCondition builds a condition from where object
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the main entry point for the ORM API
func NewClient ¶
func NewClient(db types.Database, opts ...ClientOption) *Client
NewClient creates a new ORM client
type ClientOption ¶
type ClientOption func(*Client)
ClientOption is a functional option for configuring the client
func WithTypeConverter ¶
func WithTypeConverter(tc *TypeConverter) ClientOption
WithTypeConverter sets a custom type converter
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model represents a database model with ORM query capabilities
func (*Model) CreateTyped ¶
CreateTyped creates a new record and scans it into dest
func (*Model) DeleteMany ¶
DeleteMany deletes multiple records
func (*Model) FindFirstTyped ¶
FindFirstTyped finds the first matching record and scans it into dest
func (*Model) FindManyTyped ¶
FindManyTyped finds multiple records and scans them into dest
func (*Model) FindUnique ¶
FindUnique finds a single unique record
func (*Model) FindUniqueTyped ¶
FindUniqueTyped finds a single unique record and scans it into dest
func (*Model) QueryTyped ¶
QueryTyped executes a query and scans the result into the provided destination
type OrmConformanceTests ¶
type OrmConformanceTests struct {
DriverName string
DatabaseURI string
SkipTests map[string]bool
Characteristics OrmDriverCharacteristics
NewDatabase func(uri string) (types.Database, error) // Function to create database instance
CleanupTables func(t *testing.T, db types.Database) // Driver-specific table cleanup
}
OrmConformanceTests provides a comprehensive test suite for the ORM API
func (*OrmConformanceTests) RunAll ¶
func (act *OrmConformanceTests) RunAll(t *testing.T)
RunAll runs all orm conformance tests
type OrmDriverCharacteristics ¶
type OrmDriverCharacteristics struct {
// SupportsReturning indicates if the driver supports RETURNING clause
SupportsReturning bool
// MaxConnectionPoolSize is the maximum number of connections in the pool
MaxConnectionPoolSize int
// SupportsNestedTransactions indicates if the driver supports savepoints
SupportsNestedTransactions bool
// ReturnsStringForNumbers indicates if the driver returns strings for numeric values (MySQL)
ReturnsStringForNumbers bool
}
OrmDriverCharacteristics defines driver-specific behaviors for ORM tests
type RawQuery ¶
type RawQuery struct {
// contains filtered or unexported fields
}
RawQuery represents a raw SQL query
type TypeConverter ¶
type TypeConverter struct {
// contains filtered or unexported fields
}
TypeConverter handles database-specific type conversions
func NewTypeConverter ¶
func NewTypeConverter(capabilities types.DriverCapabilities) *TypeConverter
NewTypeConverter creates a new type converter for the specified driver
func (*TypeConverter) ConvertAggregateResult ¶
func (tc *TypeConverter) ConvertAggregateResult(result map[string]any) map[string]any
ConvertAggregateResult converts aggregation results
func (*TypeConverter) ConvertFieldValue ¶
func (tc *TypeConverter) ConvertFieldValue(fieldName string, value any) any
ConvertFieldValue converts a field value for database operations
func (*TypeConverter) ConvertResult ¶
ConvertResult converts a single result map based on the driver capabilities