sql

package
v0.0.0-...-77fa510 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package sql provides a shared SQL storage implementation for xmpp-go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(ctx context.Context, db *sql.DB, dialect Dialect) error

Migrate runs all pending migrations.

Types

type Dialect

type Dialect interface {
	// Name returns the dialect name (e.g. "sqlite", "postgres", "mysql").
	Name() string

	// Placeholder returns the parameter placeholder for the nth parameter (1-indexed).
	// e.g. SQLite/MySQL return "?", PostgreSQL returns "$1", "$2", etc.
	Placeholder(n int) string

	// AutoIncrement returns the column type for an auto-incrementing primary key.
	AutoIncrement() string

	// Migrations returns the SQL migration statements for this dialect.
	Migrations() []string

	// UpsertSuffix returns the dialect-specific upsert clause.
	// For SQLite: "ON CONFLICT(...) DO UPDATE SET ..."
	// For PostgreSQL: "ON CONFLICT(...) DO UPDATE SET ..."
	// For MySQL: "ON DUPLICATE KEY UPDATE ..."
	UpsertSuffix(conflictColumns []string, updateColumns []string) string

	// BlobType returns the column type for binary data.
	BlobType() string

	// TimestampType returns the column type for timestamps.
	TimestampType() string

	// TextType returns the column type for text data.
	TextType() string

	// Now returns the SQL expression for the current timestamp.
	Now() string
}

Dialect abstracts database-specific SQL differences.

type Store

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

Store implements storage.Storage using database/sql.

func New

func New(db *sql.DB, dialect Dialect) *Store

New creates a new SQL-backed store.

func (*Store) BlockingStore

func (s *Store) BlockingStore() storage.BlockingStore

func (*Store) BookmarkStore

func (s *Store) BookmarkStore() storage.BookmarkStore

func (*Store) Close

func (s *Store) Close() error

func (*Store) Init

func (s *Store) Init(ctx context.Context) error

func (*Store) MAMStore

func (s *Store) MAMStore() storage.MAMStore

func (*Store) MUCRoomStore

func (s *Store) MUCRoomStore() storage.MUCRoomStore

func (*Store) OfflineStore

func (s *Store) OfflineStore() storage.OfflineStore

func (*Store) PubSubStore

func (s *Store) PubSubStore() storage.PubSubStore

func (*Store) RosterStore

func (s *Store) RosterStore() storage.RosterStore

func (*Store) UserStore

func (s *Store) UserStore() storage.UserStore

func (*Store) VCardStore

func (s *Store) VCardStore() storage.VCardStore

Jump to

Keyboard shortcuts

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