database

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DBTypes = createBaseTree()
View Source
var RequestTypes = []RequestType{
	Create,
	Read,
	Update,
	Delete,
}

Functions

This section is empty.

Types

type Capabilities

type Capabilities string
const (
	SupportsJSON    Capabilities = "json"
	SupportsJSONB   Capabilities = "jsonb"
	IsFile          Capabilities = "file"
	SupportsSQLLike Capabilities = "sql"
	SupportsBSON    Capabilities = "json"
)

type DBType

type DBType int
const (
	TypeSQL DBType = iota
	TypeNoSQL
	TypeGraph
	TypeTimeSeries

	TypeUndefined DBType = -1 // undefined
)

func (DBType) BaseType

func (t DBType) BaseType() Type

func (DBType) String

func (i DBType) String() string

type DBTypeNode

type DBTypeNode struct {
	Name     string
	TrueName string

	Properties map[string]string
	Children   []*DBTypeNode
}

func (*DBTypeNode) Register

func (n *DBTypeNode) Register(path ...string)

type DataSourceNameRequest

type DataSourceNameRequest interface {
	DataSourceNamer
	Request
}

type DataSourceNamer

type DataSourceNamer interface {

	// machine-readable data source string
	DSN() string

	// Type of data source, database, etc.
	Type() Type

	// Human-readable data source representation
	Info() string
}

type Database

type Database interface {
	Type() Type

	Open(context.Context) error
	Ping(context.Context) error
	Close(context.Context) error
	IsClosed() bool

	Request(context.Context, Request) (any, error)
}

type GraphType

type GraphType int
const (
	NumSupportedGraphModels GraphType = iota
)

func (GraphType) BaseType

func (t GraphType) BaseType() Type

func (GraphType) String

func (i GraphType) String() string

type NoSQL

type NoSQL interface {
	Database
	Client() NoSQLClient
}

type NoSQLClient

type NoSQLClient interface {
	SetConnectionProperties(map[string]string) // FIXME: Temporary map for connection things

	Open(context.Context) error
	Ping(context.Context) error
	Close(context.Context) error

	// TODO: Translate a request to a NoSQL client method chain
	Read(any)
	ReadMany(any)
	Create(any)
	Update(any)
	Delete(any)
}

type NoSQLModelType

type NoSQLModelType int
const (
	MongoDB   NoSQLModelType = iota // mongo
	Firestore                       // firestore
	Redis                           // redis

	NumSupportedNoSQLModels
)

func (NoSQLModelType) BaseType

func (t NoSQLModelType) BaseType() Type

func (NoSQLModelType) String

func (i NoSQLModelType) String() string

type Request

type Request interface {
	IsPrefab() bool
	ResponseOnSuccess() Response
	ResponseOnError() Response
}

type RequestType

type RequestType int
const (
	NoOp RequestType = iota - 1
	Create
	Read
	Update
	Delete
)

type Response

type Response interface {
	Code() int
	Message() string
}

type SQL

type SQL interface {
	Database
	Dialect() SQLDialect
}

type SQLDialect

type SQLDialect interface {
	Name() string

	ConnectionStringTemplate() *template.Template

	GetTemplate(RequestType) string
	GetPrefab(Request) (string, []any, error)

	Capabilities() []Capabilities

	RenderPlaceholder(index int) string
	IncreamentPlaceholder() string

	RenderTypeCast() string
	RenderCurrentTimestamp() string
	RenderValue(any) string
	QuoteRune() rune
	Quote(string) string

	ResolveType(string, []byte) (any, error)
}

type SQLDialectType

type SQLDialectType int
const (
	PostgreSQL SQLDialectType = iota // postgres
	MySQL                            // mysql
	SQLite3                          // sqlite3

	NumSupportedSQLDialects
)

func (SQLDialectType) BaseType

func (t SQLDialectType) BaseType() Type

func (SQLDialectType) String

func (i SQLDialectType) String() string

type TimeSeriesType

type TimeSeriesType int
const (
	NumSupportedTimeSeries TimeSeriesType = iota
)

func (TimeSeriesType) BaseType

func (t TimeSeriesType) BaseType() Type

func (TimeSeriesType) String

func (i TimeSeriesType) String() string

type Type

type Type interface {
	BaseType() Type
}

Jump to

Keyboard shortcuts

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