types

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateRequest

type AggregateRequest struct {
	GroupBy   []string          `json:"group_by"`
	Aggregate map[string]any    `json:"aggregate"`
	Where     map[string]any    `json:"where"`
	Having    map[string]any    `json:"having"`
	OrderBy   map[string]string `json:"order_by"`
}

AggregateRequest represents a request for aggregation

type BatchCreateRequest

type BatchCreateRequest struct {
	Data []any `json:"data"`
}

BatchCreateRequest represents a request to create multiple records

type BatchDeleteRequest

type BatchDeleteRequest struct {
	Where map[string]any `json:"where"`
}

BatchDeleteRequest represents a request to delete multiple records

type BatchUpdateRequest

type BatchUpdateRequest struct {
	Where map[string]any `json:"where"`
	Data  any            `json:"data"`
}

BatchUpdateRequest represents a request to update multiple records

type CreateRequest

type CreateRequest struct {
	Data any `json:"data"`
}

CreateRequest represents a request to create a new record

type ErrorDetail

type ErrorDetail struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Details string `json:"details,omitempty"`
}

ErrorDetail contains error information

type Meta

type Meta struct {
	ExecutionTime string `json:"execution_time"`
	QueryCount    int    `json:"query_count"`
	Timestamp     string `json:"timestamp"`
}

Meta contains metadata about the request

type Pagination

type Pagination struct {
	Page  int `json:"page"`
	Limit int `json:"limit"`
	Total int `json:"total"`
	Pages int `json:"pages"`
}

Pagination contains pagination information

type QueryParams

type QueryParams struct {
	// Pagination
	Page  int `json:"page"`
	Limit int `json:"limit"`

	// Filtering
	Where  map[string]any `json:"where"`
	Filter map[string]any `json:"filter"`

	// Sorting
	Sort    []string `json:"sort"`
	OrderBy []string `json:"order_by"`

	// Field selection
	Select []string `json:"select"`
	Fields []string `json:"fields"`

	// Relations
	Include any `json:"include"`

	// Search
	Search string `json:"search"`
	Q      string `json:"q"`
}

QueryParams represents common query parameters for data operations

func ParseQueryParams

func ParseQueryParams(params map[string][]string) (*QueryParams, error)

ParseQueryParams parses query parameters from URL values

type RawQueryRequest

type RawQueryRequest struct {
	Query      string `json:"query"`
	Parameters []any  `json:"parameters"`
}

RawQueryRequest represents a raw SQL/MongoDB query request

type Response

type Response struct {
	Success    bool         `json:"success"`
	Data       any          `json:"data"`
	Pagination *Pagination  `json:"pagination,omitempty"`
	Meta       *Meta        `json:"meta,omitempty"`
	Error      *ErrorDetail `json:"error,omitempty"`
}

Response represents the standard API response format

func NewErrorResponse

func NewErrorResponse(code, message string, details ...string) *Response

NewErrorResponse creates an error response

func NewPaginatedResponse

func NewPaginatedResponse(data any, page, limit, total int) *Response

NewPaginatedResponse creates a paginated response

func NewSuccessResponse

func NewSuccessResponse(data any) *Response

NewSuccessResponse creates a successful response

func (*Response) WithExecutionTime

func (r *Response) WithExecutionTime(duration time.Duration) *Response

WithExecutionTime adds execution time to the response

func (*Response) WithQueryCount

func (r *Response) WithQueryCount(count int) *Response

WithQueryCount adds query count to the response

type UpdateRequest

type UpdateRequest struct {
	Data any `json:"data"`
}

UpdateRequest represents a request to update a record

Jump to

Keyboard shortcuts

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