common

package
v0.0.81 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractColumnName added in v0.0.50

func ExtractColumnName(cond string) string

ExtractColumnName extracts the column name from a WHERE condition For example: "status = 'active'" returns "status"

func GetHeadSpecHeaders added in v0.0.73

func GetHeadSpecHeaders() []string

GetHeadSpecHeaders returns all headers used by HeadSpec

func IsSQLExpression added in v0.0.50

func IsSQLExpression(cond string) bool

IsSQLExpression checks if a condition is a SQL expression that shouldn't be prefixed

func IsSQLKeyword added in v0.0.50

func IsSQLKeyword(word string) bool

IsSQLKeyword checks if a string is a SQL keyword that shouldn't be treated as a column name

func IsTrivialCondition added in v0.0.55

func IsTrivialCondition(cond string) bool

IsTrivialCondition checks if a condition is trivial and always evaluates to true These conditions should be removed from WHERE clauses as they have no filtering effect

func ProcessCRUDRequest added in v0.0.65

func ProcessCRUDRequest(handler CRUDHandler, w ResponseWriter, r Request, params map[string]string)

ProcessCRUDRequest demonstrates using the CRUDHandler interface which works with resolvespec.Handler and restheadspec.Handler

func ProcessMetadataRequest added in v0.0.65

func ProcessMetadataRequest(handler CRUDHandler, w ResponseWriter, r Request, params map[string]string)

ProcessMetadataRequest demonstrates getting metadata from CRUD handlers

func QuoteIdent added in v0.0.23

func QuoteIdent(qualifier string) string

func QuoteLiteral added in v0.0.23

func QuoteLiteral(value string) string

func SanitizeWhereClause added in v0.0.55

func SanitizeWhereClause(where string, tableName string) string

SanitizeWhereClause removes trivial conditions and optionally prefixes table/relation names to columns This function should be used everywhere a WHERE statement is sent to ensure clean, efficient SQL

Parameters:

  • where: The WHERE clause string to sanitize
  • tableName: Optional table/relation name to prefix to column references (empty string to skip prefixing)

Returns:

  • The sanitized WHERE clause with trivial conditions removed and columns optionally prefixed
  • An empty string if all conditions were trivial or the input was empty

func SetCORSHeaders added in v0.0.73

func SetCORSHeaders(w ResponseWriter, config CORSConfig)

SetCORSHeaders sets CORS headers on a response writer

func ShouldUseNestedProcessor added in v0.0.20

func ShouldUseNestedProcessor(data map[string]interface{}, model interface{}, relationshipHelper RelationshipInfoProvider) bool

ShouldUseNestedProcessor determines if we should use nested CUD processing It recursively checks if the data contains: 1. A _request field at any level, OR 2. Nested relations that themselves contain further nested relations or _request fields This ensures nested processing is only used when there are deeply nested operations

func ToJSONDT added in v0.0.42

func ToJSONDT(dt time.Time) string

func TryIfInt64 added in v0.0.43

func TryIfInt64(v any, def int64) int64

TryIfInt64 - Wrapper function to quickly try and cast text to int

func ValidateAndFixPreloadWhere added in v0.0.50

func ValidateAndFixPreloadWhere(where string, relationName string) (string, error)

ValidateAndFixPreloadWhere validates that the WHERE clause for a preload contains the relation prefix (alias). If not present, it attempts to add it to column references. Returns the fixed WHERE clause and an error if it cannot be safely fixed.

func WrapHTTPRequest added in v0.0.62

func WrapHTTPRequest(w http.ResponseWriter, r *http.Request) (ResponseWriter, Request)

WrapHTTPRequest wraps standard http.ResponseWriter and *http.Request into common interfaces

Types

type APIError

type APIError struct {
	Code    string      `json:"code"`
	Message string      `json:"message"`
	Details interface{} `json:"details,omitempty"`
	Detail  string      `json:"detail,omitempty"`
}

type CORSConfig added in v0.0.73

type CORSConfig struct {
	AllowedOrigins []string
	AllowedMethods []string
	AllowedHeaders []string
	MaxAge         int
}

CORSConfig holds CORS configuration

func DefaultCORSConfig added in v0.0.73

func DefaultCORSConfig() CORSConfig

DefaultCORSConfig returns a default CORS configuration suitable for HeadSpec

type CRUDHandler added in v0.0.65

type CRUDHandler interface {
	SpecHandler

	// Handle processes API requests through router-agnostic interface
	Handle(w ResponseWriter, r Request, params map[string]string)

	// HandleGet processes GET requests for metadata
	HandleGet(w ResponseWriter, r Request, params map[string]string)
}

CRUDHandler interface for handlers that support CRUD operations This is implemented by resolvespec.Handler and restheadspec.Handler

type CRUDRequestProvider added in v0.0.20

type CRUDRequestProvider interface {
	GetRequest() string
}

CRUDRequestProvider interface for models that provide CRUD request strings

type Column

type Column struct {
	Name       string `json:"name"`
	Type       string `json:"type"`
	IsNullable bool   `json:"is_nullable"`
	IsPrimary  bool   `json:"is_primary"`
	IsUnique   bool   `json:"is_unique"`
	HasIndex   bool   `json:"has_index"`
}

type ColumnValidator

type ColumnValidator struct {
	// contains filtered or unexported fields
}

ColumnValidator validates column names against a model's fields

func NewColumnValidator

func NewColumnValidator(model interface{}) *ColumnValidator

NewColumnValidator creates a new column validator for a given model

func (*ColumnValidator) FilterRequestOptions

func (v *ColumnValidator) FilterRequestOptions(options RequestOptions) RequestOptions

FilterRequestOptions filters all column references in RequestOptions Returns a new RequestOptions with only valid columns, logging warnings for invalid ones

func (*ColumnValidator) FilterValidColumns

func (v *ColumnValidator) FilterValidColumns(columns []string) []string

FilterValidColumns filters a list of columns, returning only valid ones Logs warnings for any invalid columns

func (*ColumnValidator) GetValidColumns

func (v *ColumnValidator) GetValidColumns() []string

GetValidColumns returns a list of all valid column names for debugging purposes

func (*ColumnValidator) IsValidColumn

func (v *ColumnValidator) IsValidColumn(column string) bool

IsValidColumn checks if a column is valid Returns true if valid, false if invalid

func (*ColumnValidator) ValidateColumn

func (v *ColumnValidator) ValidateColumn(column string) error

ValidateColumn validates a single column name Returns nil if valid, error if invalid Columns prefixed with "cql" (case insensitive) are always valid Handles PostgreSQL JSON operators (-> and ->>)

func (*ColumnValidator) ValidateColumns

func (v *ColumnValidator) ValidateColumns(columns []string) error

ValidateColumns validates multiple column names Returns error with details about all invalid columns

func (*ColumnValidator) ValidateRequestOptions

func (v *ColumnValidator) ValidateRequestOptions(options RequestOptions) error

ValidateRequestOptions validates all column references in RequestOptions

type ComputedColumn

type ComputedColumn struct {
	Name       string `json:"name"`
	Expression string `json:"expression"`
}

type CustomOperator

type CustomOperator struct {
	Name string `json:"name"`
	SQL  string `json:"sql"`
}

type Database

type Database interface {
	// Core query operations
	NewSelect() SelectQuery
	NewInsert() InsertQuery
	NewUpdate() UpdateQuery
	NewDelete() DeleteQuery

	// Raw SQL execution
	Exec(ctx context.Context, query string, args ...interface{}) (Result, error)
	Query(ctx context.Context, dest interface{}, query string, args ...interface{}) error

	// Transaction support
	BeginTx(ctx context.Context) (Database, error)
	CommitTx(ctx context.Context) error
	RollbackTx(ctx context.Context) error
	RunInTransaction(ctx context.Context, fn func(Database) error) error
}

Database interface designed to work with both GORM and Bun

func ProcessWithAnyHandler added in v0.0.65

func ProcessWithAnyHandler(handler SpecHandler) Database

ProcessWithAnyHandler demonstrates using the base SpecHandler interface which works with any handler type (resolvespec, restheadspec, or funcspec)

type DeleteQuery

type DeleteQuery interface {
	Model(model interface{}) DeleteQuery
	Table(table string) DeleteQuery
	Where(query string, args ...interface{}) DeleteQuery

	// Execution
	Exec(ctx context.Context) (Result, error)
}

DeleteQuery interface for building DELETE queries

type FilterOption

type FilterOption struct {
	Column        string      `json:"column"`
	Operator      string      `json:"operator"`
	Value         interface{} `json:"value"`
	LogicOperator string      `json:"logic_operator"` // "AND" or "OR" - how this filter combines with previous filters
}

type HTTPHandlerFunc

type HTTPHandlerFunc func(ResponseWriter, Request)

HTTPHandlerFunc type for HTTP handlers

type InsertQuery

type InsertQuery interface {
	Model(model interface{}) InsertQuery
	Table(table string) InsertQuery
	Value(column string, value interface{}) InsertQuery
	OnConflict(action string) InsertQuery
	Returning(columns ...string) InsertQuery

	// Execution
	Exec(ctx context.Context) (Result, error)
}

InsertQuery interface for building INSERT queries

type Metadata

type Metadata struct {
	Total     int64  `json:"total"`
	Count     int64  `json:"count"`
	Filtered  int64  `json:"filtered"`
	Limit     int    `json:"limit"`
	Offset    int    `json:"offset"`
	RowNumber *int64 `json:"row_number,omitempty"`
}

type ModelRegistry

type ModelRegistry interface {
	RegisterModel(name string, model interface{}) error
	GetModel(name string) (interface{}, error)
	GetAllModels() map[string]interface{}
	GetModelByEntity(schema, entity string) (interface{}, error)
}

ModelRegistry manages model registration and retrieval

type NestedCUDProcessor added in v0.0.20

type NestedCUDProcessor struct {
	// contains filtered or unexported fields
}

NestedCUDProcessor handles recursive processing of nested object graphs

func NewNestedCUDProcessor added in v0.0.20

func NewNestedCUDProcessor(db Database, registry ModelRegistry, relationshipHelper RelationshipInfoProvider) *NestedCUDProcessor

NewNestedCUDProcessor creates a new nested CUD processor

func (*NestedCUDProcessor) ProcessNestedCUD added in v0.0.20

func (p *NestedCUDProcessor) ProcessNestedCUD(
	ctx context.Context,
	operation string,
	data map[string]interface{},
	model interface{},
	parentIDs map[string]interface{},
	tableName string,
) (*ProcessResult, error)

ProcessNestedCUD recursively processes nested object graphs for Create, Update, Delete operations with automatic foreign key resolution

type Parameter

type Parameter struct {
	Name     string `json:"name"`
	Value    string `json:"value"`
	Sequence *int   `json:"sequence"`
}

type PreloadOption

type PreloadOption struct {
	Relation    string            `json:"relation"`
	Columns     []string          `json:"columns"`
	OmitColumns []string          `json:"omit_columns"`
	Sort        []SortOption      `json:"sort"`
	Filters     []FilterOption    `json:"filters"`
	Where       string            `json:"where"`
	Limit       *int              `json:"limit"`
	Offset      *int              `json:"offset"`
	Updatable   *bool             `json:"updateable"`  // if true, the relation can be updated
	ComputedQL  map[string]string `json:"computed_ql"` // Computed columns as SQL expressions
	Recursive   bool              `json:"recursive"`   // if true, preload recursively up to 5 levels

	// Relationship keys from XFiles - used to build proper foreign key filters
	PrimaryKey string `json:"primary_key"` // Primary key of the related table
	RelatedKey string `json:"related_key"` // For child tables: column in child that references parent
	ForeignKey string `json:"foreign_key"` // For parent tables: column in current table that references parent
}

type PrimaryKeyNameProvider

type PrimaryKeyNameProvider interface {
	GetIDName() string
}

PrimaryKeyNameProvider interface for models that provide primary key column names

type ProcessResult added in v0.0.20

type ProcessResult struct {
	ID           interface{}            // The ID of the processed record
	AffectedRows int64                  // Number of rows affected
	Data         map[string]interface{} // The processed data
	RelationData map[string]interface{} // Data from processed relations
}

ProcessResult contains the result of processing a CUD operation

type QueryHandler added in v0.0.65

type QueryHandler interface {
	SpecHandler
}

QueryHandler interface for handlers that execute SQL queries This is implemented by funcspec.Handler Note: funcspec uses standard http.ResponseWriter and *http.Request instead of common interfaces

type RelationshipInfo added in v0.0.20

type RelationshipInfo struct {
	FieldName    string
	JSONName     string
	RelationType string // "belongsTo", "hasMany", "hasOne", "many2many"
	ForeignKey   string
	References   string
	JoinTable    string
	RelatedModel interface{}
}

RelationshipInfo contains information about a model relationship

type RelationshipInfoProvider added in v0.0.20

type RelationshipInfoProvider interface {
	GetRelationshipInfo(modelType reflect.Type, relationName string) *RelationshipInfo
}

RelationshipInfoProvider interface for handlers that can provide relationship info

type Request

type Request interface {
	Method() string
	URL() string
	Header(key string) string
	AllHeaders() map[string]string // Get all headers as a map
	Body() ([]byte, error)
	PathParam(key string) string
	QueryParam(key string) string
	AllQueryParams() map[string]string // Get all query parameters as a map
	UnderlyingRequest() *http.Request  // Get the underlying *http.Request for forwarding to other handlers
}

Request interface abstracts HTTP request

type RequestBody

type RequestBody struct {
	Operation string         `json:"operation"`
	Data      interface{}    `json:"data"`
	ID        *int64         `json:"id"`
	Options   RequestOptions `json:"options"`
}

type RequestOptions

type RequestOptions struct {
	Preload         []PreloadOption  `json:"preload"`
	Columns         []string         `json:"columns"`
	OmitColumns     []string         `json:"omit_columns"`
	Filters         []FilterOption   `json:"filters"`
	Sort            []SortOption     `json:"sort"`
	Limit           *int             `json:"limit"`
	Offset          *int             `json:"offset"`
	CustomOperators []CustomOperator `json:"customOperators"`
	ComputedColumns []ComputedColumn `json:"computedColumns"`
	Parameters      []Parameter      `json:"parameters"`

	// Cursor pagination
	CursorForward  string  `json:"cursor_forward"`
	CursorBackward string  `json:"cursor_backward"`
	FetchRowNumber *string `json:"fetch_row_number"`
}

type Response

type Response struct {
	Success  bool        `json:"success"`
	Data     interface{} `json:"data"`
	Metadata *Metadata   `json:"metadata,omitempty"`
	Error    *APIError   `json:"error,omitempty"`
}

Response structures

type ResponseWriter

type ResponseWriter interface {
	SetHeader(key, value string)
	WriteHeader(statusCode int)
	Write(data []byte) (int, error)
	WriteJSON(data interface{}) error
	UnderlyingResponseWriter() http.ResponseWriter // Get the underlying http.ResponseWriter for forwarding to other handlers
}

ResponseWriter interface abstracts HTTP response

type Result

type Result interface {
	RowsAffected() int64
	LastInsertId() (int64, error)
}

Result interface for query execution results

type RouteRegistration

type RouteRegistration interface {
	Methods(methods ...string) RouteRegistration
	PathPrefix(prefix string) RouteRegistration
}

RouteRegistration allows method chaining for route configuration

type Router

type Router interface {
	HandleFunc(pattern string, handler HTTPHandlerFunc) RouteRegistration
	ServeHTTP(w ResponseWriter, r Request)
}

Router interface for HTTP router abstraction

type SchemaProvider

type SchemaProvider interface {
	SchemaName() string
}

SchemaProvider interface for models that provide schema names

type SelectQuery

type SelectQuery interface {
	Model(model interface{}) SelectQuery
	Table(table string) SelectQuery
	Column(columns ...string) SelectQuery
	ColumnExpr(query string, args ...interface{}) SelectQuery
	Where(query string, args ...interface{}) SelectQuery
	WhereOr(query string, args ...interface{}) SelectQuery
	Join(query string, args ...interface{}) SelectQuery
	LeftJoin(query string, args ...interface{}) SelectQuery
	Preload(relation string, conditions ...interface{}) SelectQuery
	PreloadRelation(relation string, apply ...func(SelectQuery) SelectQuery) SelectQuery
	Order(order string) SelectQuery
	Limit(n int) SelectQuery
	Offset(n int) SelectQuery
	Group(group string) SelectQuery
	Having(having string, args ...interface{}) SelectQuery

	// Execution methods
	Scan(ctx context.Context, dest interface{}) error
	ScanModel(ctx context.Context) error
	Count(ctx context.Context) (int, error)
	Exists(ctx context.Context) (bool, error)
}

SelectQuery interface for building SELECT queries (compatible with both GORM and Bun)

type SortOption

type SortOption struct {
	Column    string `json:"column"`
	Direction string `json:"direction"`
}

type SpecHandler added in v0.0.65

type SpecHandler interface {
	// GetDatabase returns the underlying database connection
	GetDatabase() Database
}

SpecHandler interface represents common functionality across all spec handlers This is the base interface implemented by:

  • resolvespec.Handler: Handles CRUD operations via request body with explicit operation field
  • restheadspec.Handler: Handles CRUD operations via HTTP methods (GET/POST/PUT/DELETE)
  • funcspec.Handler: Handles custom SQL query execution with dynamic parameters

The interface hierarchy is:

SpecHandler (base)
├── CRUDHandler (resolvespec, restheadspec)
└── QueryHandler (funcspec)

type SqlDate added in v0.0.42

type SqlDate time.Time

SqlDate - Implementation of SqlTime with some interfaces.

func SqlDateNow added in v0.0.42

func SqlDateNow() SqlDate

func (SqlDate) Int64 added in v0.0.42

func (t SqlDate) Int64() int64

Int64 - Override date format in unix epoch

func (SqlDate) MarshalJSON added in v0.0.42

func (t SqlDate) MarshalJSON() ([]byte, error)

MarshalJSON - Override JSON format of time

func (*SqlDate) Scan added in v0.0.42

func (t *SqlDate) Scan(value interface{}) error

Scan - Scan custom date from sql

func (SqlDate) String added in v0.0.42

func (t SqlDate) String() string

String - Override String format of time

func (*SqlDate) UnmarshalJSON added in v0.0.42

func (t *SqlDate) UnmarshalJSON(b []byte) error

UnmarshalJSON - Override JSON format of time

func (SqlDate) Value added in v0.0.42

func (t SqlDate) Value() (driver.Value, error)

Value - SQL Value of custom date

type SqlFloat64 added in v0.0.42

type SqlFloat64 sql.NullFloat64

SqlFloat64 - SQL Int

func (SqlFloat64) MarshalJSON added in v0.0.42

func (n SqlFloat64) MarshalJSON() ([]byte, error)

MarshalJSON - Override JSON format of time

func (*SqlFloat64) Scan added in v0.0.42

func (n *SqlFloat64) Scan(value interface{}) error

Scan -

func (SqlFloat64) String added in v0.0.42

func (n SqlFloat64) String() string

String -

func (*SqlFloat64) UnmarshalJSON added in v0.0.42

func (n *SqlFloat64) UnmarshalJSON(b []byte) error

UnmarshalJSON -

func (SqlFloat64) Value added in v0.0.42

func (n SqlFloat64) Value() (driver.Value, error)

Value -

type SqlInt16 added in v0.0.42

type SqlInt16 int16

SqlInt16 - A Int16 that supports SQL string

func (SqlInt16) MarshalJSON added in v0.0.42

func (n SqlInt16) MarshalJSON() ([]byte, error)

MarshalJSON - Override JSON format of time

func (*SqlInt16) Scan added in v0.0.42

func (n *SqlInt16) Scan(value interface{}) error

Scan -

func (SqlInt16) String added in v0.0.42

func (n SqlInt16) String() string

String - Override String format of ZNullInt32

func (*SqlInt16) UnmarshalJSON added in v0.0.42

func (n *SqlInt16) UnmarshalJSON(b []byte) error

UnmarshalJSON - Overre JidSON format of ZNullInt32

func (SqlInt16) Value added in v0.0.42

func (n SqlInt16) Value() (driver.Value, error)

Value -

type SqlInt32 added in v0.0.42

type SqlInt32 int32

SqlInt32 - A int32 that supports SQL string

func (SqlInt32) MarshalJSON added in v0.0.42

func (n SqlInt32) MarshalJSON() ([]byte, error)

MarshalJSON - Override JSON format of time

func (*SqlInt32) Scan added in v0.0.42

func (n *SqlInt32) Scan(value interface{}) error

Scan -

func (SqlInt32) String added in v0.0.42

func (n SqlInt32) String() string

String - Override String format of ZNullInt32

func (*SqlInt32) UnmarshalJSON added in v0.0.42

func (n *SqlInt32) UnmarshalJSON(b []byte) error

UnmarshalJSON - Overre JidSON format of ZNullInt32

func (SqlInt32) Value added in v0.0.42

func (n SqlInt32) Value() (driver.Value, error)

Value -

type SqlInt64 added in v0.0.42

type SqlInt64 int64

SqlInt64 - A int64 that supports SQL string

func (SqlInt64) MarshalJSON added in v0.0.42

func (n SqlInt64) MarshalJSON() ([]byte, error)

MarshalJSON - Override JSON format of time

func (*SqlInt64) Scan added in v0.0.42

func (n *SqlInt64) Scan(value interface{}) error

Scan -

func (SqlInt64) String added in v0.0.42

func (n SqlInt64) String() string

String - Override String format of ZNullInt32

func (*SqlInt64) UnmarshalJSON added in v0.0.42

func (n *SqlInt64) UnmarshalJSON(b []byte) error

UnmarshalJSON - Overre JidSON format of ZNullInt32

func (SqlInt64) Value added in v0.0.42

func (n SqlInt64) Value() (driver.Value, error)

Value -

type SqlJSONB added in v0.0.42

type SqlJSONB []byte

SqlJSONB - Nullable JSONB String

func (SqlJSONB) AsMap added in v0.0.42

func (n SqlJSONB) AsMap() (map[string]any, error)

func (SqlJSONB) AsSlice added in v0.0.42

func (n SqlJSONB) AsSlice() ([]any, error)

func (SqlJSONB) MarshalJSON added in v0.0.42

func (n SqlJSONB) MarshalJSON() ([]byte, error)

MarshalJSON - Override JSON format of time

func (*SqlJSONB) Scan added in v0.0.42

func (n *SqlJSONB) Scan(value interface{}) error

Scan - Implements sql.Scanner for reading JSONB from database

func (*SqlJSONB) UnmarshalJSON added in v0.0.42

func (n *SqlJSONB) UnmarshalJSON(b []byte) error

UnmarshalJSON - Override JSON

func (SqlJSONB) Value added in v0.0.42

func (n SqlJSONB) Value() (driver.Value, error)

Value - Implements driver.Valuer for writing JSONB to database

type SqlTime added in v0.0.42

type SqlTime time.Time

////////////////////// SqlTime ///////////////////////// SqlTime - Implementation of SqlTime with some interfaces.

func SqlTimeNow added in v0.0.42

func SqlTimeNow() SqlTime

func (SqlTime) Format added in v0.0.42

func (t SqlTime) Format(form string) string

Format - Format Function

func (SqlTime) Int64 added in v0.0.42

func (t SqlTime) Int64() int64

Int64 - Override Time format in unix epoch

func (SqlTime) MarshalJSON added in v0.0.42

func (t SqlTime) MarshalJSON() ([]byte, error)

MarshalJSON - Override JSON format of time

func (*SqlTime) Scan added in v0.0.42

func (t *SqlTime) Scan(value interface{}) error

Scan - Scan custom date from sql

func (SqlTime) String added in v0.0.42

func (t SqlTime) String() string

String - Override String format of time

func (*SqlTime) UnmarshalJSON added in v0.0.42

func (t *SqlTime) UnmarshalJSON(b []byte) error

UnmarshalJSON - Override JSON format of time

func (SqlTime) Value added in v0.0.42

func (t SqlTime) Value() (driver.Value, error)

Value - SQL Value of custom date

type SqlTimeStamp added in v0.0.42

type SqlTimeStamp time.Time

SqlTimeStamp - Implementation of SqlTimeStamp with some interfaces.

func SqlTimeStampNow added in v0.0.42

func SqlTimeStampNow() SqlTimeStamp

func (SqlTimeStamp) Format added in v0.0.42

func (t SqlTimeStamp) Format(layout string) string

Format - Formats the time

func (SqlTimeStamp) GetTime added in v0.0.42

func (t SqlTimeStamp) GetTime() time.Time

GetTime - Returns Time

func (SqlTimeStamp) MarshalJSON added in v0.0.42

func (t SqlTimeStamp) MarshalJSON() ([]byte, error)

MarshalJSON - Override JSON format of time

func (*SqlTimeStamp) Scan added in v0.0.42

func (t *SqlTimeStamp) Scan(value interface{}) error

Scan - Scan custom date from sql

func (*SqlTimeStamp) SetTime added in v0.0.42

func (t *SqlTimeStamp) SetTime(pTime time.Time)

SetTime - Returns Time

func (SqlTimeStamp) String added in v0.0.42

func (t SqlTimeStamp) String() string

String - Override String format of time

func (*SqlTimeStamp) UnmarshalJSON added in v0.0.42

func (t *SqlTimeStamp) UnmarshalJSON(b []byte) error

UnmarshalJSON - Override JSON format of time

func (SqlTimeStamp) Value added in v0.0.42

func (t SqlTimeStamp) Value() (driver.Value, error)

Value - SQL Value of custom date

type SqlUUID added in v0.0.43

type SqlUUID sql.NullString

SqlUUID - Nullable UUID String

func (SqlUUID) MarshalJSON added in v0.0.43

func (n SqlUUID) MarshalJSON() ([]byte, error)

MarshalJSON - Override JSON format of time

func (*SqlUUID) Scan added in v0.0.43

func (n *SqlUUID) Scan(value interface{}) error

Scan -

func (*SqlUUID) UnmarshalJSON added in v0.0.43

func (n *SqlUUID) UnmarshalJSON(b []byte) error

UnmarshalJSON - Override JSON

func (SqlUUID) Value added in v0.0.43

func (n SqlUUID) Value() (driver.Value, error)

Value -

type StandardRequest added in v0.0.62

type StandardRequest struct {
	// contains filtered or unexported fields
}

StandardRequest adapts *http.Request to Request interface

func (*StandardRequest) AllHeaders added in v0.0.62

func (s *StandardRequest) AllHeaders() map[string]string

func (*StandardRequest) AllQueryParams added in v0.0.62

func (s *StandardRequest) AllQueryParams() map[string]string

func (*StandardRequest) Body added in v0.0.62

func (s *StandardRequest) Body() ([]byte, error)

func (*StandardRequest) Header added in v0.0.62

func (s *StandardRequest) Header(key string) string

func (*StandardRequest) Method added in v0.0.62

func (s *StandardRequest) Method() string

func (*StandardRequest) PathParam added in v0.0.62

func (s *StandardRequest) PathParam(key string) string

func (*StandardRequest) QueryParam added in v0.0.62

func (s *StandardRequest) QueryParam(key string) string

func (*StandardRequest) URL added in v0.0.62

func (s *StandardRequest) URL() string

func (*StandardRequest) UnderlyingRequest added in v0.0.72

func (s *StandardRequest) UnderlyingRequest() *http.Request

type StandardResponseWriter added in v0.0.62

type StandardResponseWriter struct {
	// contains filtered or unexported fields
}

StandardResponseWriter adapts http.ResponseWriter to ResponseWriter interface

func (*StandardResponseWriter) SetHeader added in v0.0.62

func (s *StandardResponseWriter) SetHeader(key, value string)

func (*StandardResponseWriter) UnderlyingResponseWriter added in v0.0.72

func (s *StandardResponseWriter) UnderlyingResponseWriter() http.ResponseWriter

func (*StandardResponseWriter) Write added in v0.0.62

func (s *StandardResponseWriter) Write(data []byte) (int, error)

func (*StandardResponseWriter) WriteHeader added in v0.0.62

func (s *StandardResponseWriter) WriteHeader(statusCode int)

func (*StandardResponseWriter) WriteJSON added in v0.0.62

func (s *StandardResponseWriter) WriteJSON(data interface{}) error

type TableAliasProvider added in v0.0.20

type TableAliasProvider interface {
	TableAlias() string
}

type TableMetadata

type TableMetadata struct {
	Schema    string   `json:"schema"`
	Table     string   `json:"table"`
	Columns   []Column `json:"columns"`
	Relations []string `json:"relations"`
}

type TableNameProvider

type TableNameProvider interface {
	TableName() string
}

TableNameProvider interface for models that provide table names

type UpdateQuery

type UpdateQuery interface {
	Model(model interface{}) UpdateQuery
	Table(table string) UpdateQuery
	Set(column string, value interface{}) UpdateQuery
	SetMap(values map[string]interface{}) UpdateQuery
	Where(query string, args ...interface{}) UpdateQuery
	Returning(columns ...string) UpdateQuery

	// Execution
	Exec(ctx context.Context) (Result, error)
}

UpdateQuery interface for building UPDATE queries

type ValidateAndUnwrapModelResult added in v0.0.80

type ValidateAndUnwrapModelResult struct {
	ModelType    reflect.Type
	Model        interface{}
	ModelPtr     interface{}
	OriginalType reflect.Type
}

ValidateAndUnwrapModelResult contains the result of model validation

func ValidateAndUnwrapModel added in v0.0.80

func ValidateAndUnwrapModel(model interface{}) (*ValidateAndUnwrapModelResult, error)

ValidateAndUnwrapModel validates that a model is a struct type and unwraps pointers, slices, and arrays to get to the base struct type. Returns an error if the model is not a valid struct type.

Directories

Path Synopsis
adapters

Jump to

Keyboard shortcuts

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