Versions in this module Expand all Collapse all v0 v0.5.0 Jul 25, 2026 Changes in this version + const AttrArgsCount + const AttrOperation + const AttrStatement + const AttrSystem + const AttrSystemSQLite + const DrizzleTable + const StatementBreakpoint + var ErrAuditTableMissing = errors.New(...) + var ErrBusy = errors.New("drops/sqlite: database is busy (SQLITE_BUSY)") + var ErrConcurrencyConflict = errors.New("drops/sqlite: event store concurrency conflict") + var ErrEmptyKey = errors.New("drops/sqlite: idempotency key cannot be empty") + var ErrLocked = errors.New("drops/sqlite: database is locked (SQLITE_LOCKED)") + var ErrNoHandler = errors.New("drops/sqlite: OutboxWorker has no handler") + var ErrSchemaRequired = errors.New("drops/sqlite: Push requires a non-nil schema") + var ErrSubjectMissing = errors.New("drops/sqlite: entity is guarded but ctx has no subject") + var ErrTenantMismatch = errors.New("drops/sqlite: row tenant disagrees with ctx tenant") + var ErrTenantMissing = errors.New("drops/sqlite: entity is tenant-scoped but ctx has no tenant") + var ErrUnauthorized = errors.New("drops/sqlite: unauthorized") + func Abs(e any) drops.Expression + func Acos(e any) drops.Expression + func ActorFrom(ctx context.Context) string + func As(e drops.Expression, alias string) drops.Expression + func Asin(e any) drops.Expression + func Atan(e any) drops.Expression + func Avg(e drops.Expression) drops.Expression + func AvgDistinct(e drops.Expression) drops.Expression + func Between(left, low, high any) drops.Expression + func Cast(e any, typeSQL string) drops.Expression + func CastAs(e any, typeSQL string) drops.Expression + func Ceil(e any) drops.Expression + func Chr(args ...any) drops.Expression + func Coalesce(args ...any) drops.Expression + func ColumnExists(ctx context.Context, db *DB, table, column string) (bool, error) + func Concat(args ...any) drops.Expression + func ConcatOp(left, right any) drops.Expression + func ConcatWS(sep any, args ...any) drops.Expression + func Cos(e any) drops.Expression + func Count(e drops.Expression) drops.Expression + func CountAll() drops.Expression + func CountDistinct(e drops.Expression) drops.Expression + func CumeDist() drops.Expression + func CurrentDate() drops.Expression + func CurrentTime() drops.Expression + func CurrentTimestamp() drops.Expression + func DateOf(timeval any, modifiers ...any) drops.Expression + func DateTime(timeval any, modifiers ...any) drops.Expression + func DenseRank() drops.Expression + func Div(left, right any) drops.Expression + func Eq(left, right any) drops.Expression + func Exists(q drops.Expression) drops.Expression + func Exp(e any) drops.Expression + func ExponentialJitter(base, maxN time.Duration) func(attempt int) time.Duration + func Filter(agg, pred drops.Expression) drops.Expression + func FirstValue(expr any) drops.Expression + func Floor(e any) drops.Expression + func Format(format any, args ...any) drops.Expression + func Func(name string, args ...any) drops.Expression + func Glob(left, pattern any) drops.Expression + func Greatest(args ...any) drops.Expression + func GroupConcat(e any, sep ...any) drops.Expression + func Gt(left, right any) drops.Expression + func Gte(left, right any) drops.Expression + func Hex(e any) drops.Expression + func IfNull(a, b any) drops.Expression + func In(left any, values ...any) drops.Expression + func InSub(value any, sub drops.Expression) drops.Expression + func IndexExists(ctx context.Context, db *DB, index string) (bool, error) + func Instr(e, sub any) drops.Expression + func IsDistinctFrom(left, right any) drops.Expression + func IsNotDistinctFrom(left, right any) drops.Expression + func IsNotNull(e any) drops.Expression + func IsNull(e any) drops.Expression + func IsPII(v any) bool + func IsSagaError(err error) bool + func JSONArray(args ...any) drops.Expression + func JSONArrayLength(e any, path ...any) drops.Expression + func JSONExtract(e, path any) drops.Expression + func JSONGet(e, path any) drops.Expression + func JSONGetText(e, path any) drops.Expression + func JSONGroupArray(e any) drops.Expression + func JSONGroupObject(k, v any) drops.Expression + func JSONHasKey(col ColRef, path ...string) drops.Expression + func JSONInsert(e any, args ...any) drops.Expression + func JSONObject(args ...any) drops.Expression + func JSONPatch(target, patch any) drops.Expression + func JSONQuote(e any) drops.Expression + func JSONRemove(e any, paths ...any) drops.Expression + func JSONReplace(e any, args ...any) drops.Expression + func JSONSet(e any, args ...any) drops.Expression + func JSONType(e any, path ...any) drops.Expression + func JSONValid(e any) drops.Expression + func JulianDay(timeval any, modifiers ...any) drops.Expression + func LTrim(e any, chars ...any) drops.Expression + func Lag(expr any, args ...any) drops.Expression + func LastValue(expr any) drops.Expression + func Lead(expr any, args ...any) drops.Expression + func Least(args ...any) drops.Expression + func Length(e any) drops.Expression + func Like(left, pattern any) drops.Expression + func LikeEscape(left, pattern, esc any) drops.Expression + func Ln(e any) drops.Expression + func Log(e any, base ...any) drops.Expression + func LoggerHook(log LoggerFunc, opts ...LoggerOptions) drops.Hook + func Lower(e drops.Expression) drops.Expression + func Lt(left, right any) drops.Expression + func Lte(left, right any) drops.Expression + func Max(e drops.Expression) drops.Expression + func MermaidDiagram(s *Schema) string + func Min(e drops.Expression) drops.Expression + func Minus(left, right any) drops.Expression + func Mod(a, b any) drops.Expression + func Mul(left, right any) drops.Expression + func N1Hook(ctx context.Context, e drops.QueryEvent) + func Ne(left, right any) drops.Expression + func Not(p drops.Expression) drops.Expression + func NotBetween(left, low, high any) drops.Expression + func NotExists(q drops.Expression) drops.Expression + func NotIn(left any, values ...any) drops.Expression + func NotInSub(value any, sub drops.Expression) drops.Expression + func NotLike(left, pattern any) drops.Expression + func Now() drops.Expression + func NthValue(expr, n any) drops.Expression + func Ntile(n any) drops.Expression + func NullIf(a, b any) drops.Expression + func OctetLength(e any) drops.Expression + func Over(fn drops.Expression, win *Window) drops.Expression + func PII(value any) any + func PercentRank() drops.Expression + func Plus(left, right any) drops.Expression + func Power(a, b any) drops.Expression + func Printf(format any, args ...any) drops.Expression + func Quote(e any) drops.Expression + func RTrim(e any, chars ...any) drops.Expression + func Random() drops.Expression + func Rank() drops.Expression + func Regexp(left, pattern any) drops.Expression + func Replace(e, from, to any) drops.Expression + func Round(e any, digits ...int) drops.Expression + func RowNumber() drops.Expression + func RunJSON[T any](s *IdempotencyStore, ctx context.Context, key string, ...) (T, error) + func SagaStateGet[T any](s *SagaState, key string) (T, bool) + func Sign(e any) drops.Expression + func Sin(e any) drops.Expression + func Sqrt(e any) drops.Expression + func StrfTime(format, timeval any, modifiers ...any) drops.Expression + func SubjectFrom(ctx context.Context) (any, bool) + func Subquery(q drops.Expression) drops.Expression + func Substr(e, from any, count ...any) drops.Expression + func Sum(e drops.Expression) drops.Expression + func SumDistinct(e drops.Expression) drops.Expression + func TableExists(ctx context.Context, db *DB, table string) (bool, error) + func Tan(e any) drops.Expression + func TenantFrom(ctx context.Context) (any, bool) + func TestTx(t TB, db *DB, ctx context.Context, fn func(tx *DB)) + func TimeOf(timeval any, modifiers ...any) drops.Expression + func Total(e drops.Expression) drops.Expression + func TriggerExists(ctx context.Context, db *DB, trigger string) (bool, error) + func Trim(e any, chars ...any) drops.Expression + func Trunc(e any) drops.Expression + func Unhex(e any) drops.Expression + func Unicode(e any) drops.Expression + func UnixEpoch(timeval any, modifiers ...any) drops.Expression + func Upper(e drops.Expression) drops.Expression + func WithActor(ctx context.Context, actor any) context.Context + func WithN1Detector(ctx context.Context) (derived context.Context, finish func(threshold int) N1Report) + func WithSubject(ctx context.Context, subject any) context.Context + func WithTenant(ctx context.Context, tenant any) context.Context + type AggregateSnapshot struct + AggregateID string + AggregateType string + CreatedAt time.Time + State json.RawMessage + Version int64 + type AuditCols struct + CreatedBy *Col[T] + UpdatedBy *Col[T] + func Audit[T any](t *Table, target *Col[T]) AuditCols[T] + type AuditEvent struct + Actor string + Entity string + Op string + PK json.RawMessage + Payload json.RawMessage + type AuditLog struct + func NewAuditLog(db *DB, table string) *AuditLog + func (a *AuditLog) Record(tx *DB, ctx context.Context, ev AuditEvent) error + type AuditMixin struct + Cols AuditCols[T] + Target *Col[T] + func (m *AuditMixin[T]) Apply(t *Table) + type Backfill struct + func NewBackfill(db *DB, name string) *Backfill + func (b *Backfill) ChunkSize(n int) *Backfill + func (b *Backfill) Fetch(fn func(ctx context.Context, lastID int64, limit int) ([]int64, int64, error)) *Backfill + func (b *Backfill) OnProgress(fn func(processed, lastID int64)) *Backfill + func (b *Backfill) Process(fn func(ctx context.Context, tx *DB, ids []int64) error) *Backfill + func (b *Backfill) Reset(ctx context.Context) error + func (b *Backfill) Run(ctx context.Context) error + func (b *Backfill) StateTable(name string) *Backfill + func (b *Backfill) Status(ctx context.Context) (BackfillStatus, error) + func (b *Backfill) Throttle(d time.Duration) *Backfill + type BackfillStatus struct + CompletedAt *time.Time + LastError string + LastID int64 + Name string + Processed int64 + UpdatedAt time.Time + type CTE struct + func CTEDef(name string, query drops.Expression, columns ...string) *CTE + func (c *CTE) Col(col string) drops.Expression + func (c *CTE) Name() string + func (c *CTE) Ref() drops.Expression + type CaseExpr struct + func Case() *CaseExpr + func CaseOn(value any) *CaseExpr + func (c *CaseExpr) Else(value any) *CaseExpr + func (c *CaseExpr) End() drops.Expression + func (c *CaseExpr) When(cond, value any) *CaseExpr type Col + func EnumCol(t *Table, col string, values ...string) *Col[string] + func (c *Col[T]) AsPII() *Col[T] type Column + func (c *Column) IsPII() bool + type Cursor string + func EncodeCursor(spec CursorSpec, values ...any) (Cursor, error) + func (c Cursor) Decode() ([]any, error) + type CursorSpec struct + Keys []OrderKey + func NewCursorSpec(keys ...OrderKey) CursorSpec + type CustomGuard func(ctx context.Context) (drops.Expression, error) + func (g CustomGuard) Predicate(ctx context.Context) (drops.Expression, error) type DB + func (db *DB) RetryPolicyValue() RetryPolicy + func (db *DB) Tracer() Tracer + func (db *DB) WithRetry(policy RetryPolicy) *DB + func (db *DB) WithTracer(t Tracer) *DB type DeleteBuilder + func (d *DeleteBuilder) DB() *DB + func (d *DeleteBuilder) IsUnscoped() bool + func (d *DeleteBuilder) Table() *Table + func (d *DeleteBuilder) Unscoped() *DeleteBuilder + func (d *DeleteBuilder) Wheres() []drops.Expression + type DeleteHook interface + BeforeDelete func(d *DeleteBuilder) drops.Expression + type DeleteHookFunc func(*DeleteBuilder) drops.Expression + func (f DeleteHookFunc) BeforeDelete(d *DeleteBuilder) drops.Expression + type DriftReport struct + InSync bool + PendingMigrations []string + UnauthorizedChanges []string + func DetectDrift(repo, live *Snapshot) DriftReport + func (r DriftReport) HasPendingMigrations() bool + func (r DriftReport) HasUnauthorizedChanges() bool + type DrizzleEntry struct + Breakpoints bool + Hash string + SQL string + Tag string + When int64 + type DrizzleHook func(ctx context.Context, tx *DB, entry DrizzleEntry) error + type DrizzleMigrator struct + func NewDrizzleMigrator(db *DB, fsys fs.FS, dir string) *DrizzleMigrator + func (d *DrizzleMigrator) AfterEach(h DrizzleHook) *DrizzleMigrator + func (d *DrizzleMigrator) BeforeEach(h DrizzleHook) *DrizzleMigrator + func (d *DrizzleMigrator) LoadEntries() ([]DrizzleEntry, error) + func (d *DrizzleMigrator) Status(ctx context.Context) ([]DrizzleStatus, error) + func (d *DrizzleMigrator) Up(ctx context.Context) error + func (d *DrizzleMigrator) WithTable(table string) *DrizzleMigrator + type DrizzleStatus struct + Applied bool + Hash string + Tag string + When int64 + type EmitOptions struct + AggregateID string + AggregateType string + Headers map[string]string type Entity + func NewAutoEntity[T any](name string) *Entity[T] + func WithAudit[T any](e *Entity[T], log *AuditLog) *Entity[T] + func (e *Entity[T]) AuthorizeWith(g Guard) *Entity[T] + func (e *Entity[T]) CreateMany(db *DB, ctx context.Context, rows []T) (drops.Result, error) + func (e *Entity[T]) HasCache() bool + func (e *Entity[T]) Page(db *DB) *PageBuilder[T] + func (e *Entity[T]) Patch(db *DB, ctx context.Context, id any, ops ...PatchOp) (drops.Result, error) + func (e *Entity[T]) Restore(db *DB, ctx context.Context, id any, sd SoftDeleteCols) (drops.Result, error) + func (e *Entity[T]) ScopeByTenant(col ColRef) *Entity[T] + func (e *Entity[T]) SoftDeleteByID(db *DB, ctx context.Context, id any, sd SoftDeleteCols) (drops.Result, error) + func (e *Entity[T]) WithCache(c cache.Cache, ttl time.Duration) *Entity[T] + type EntityCache struct + type Enum struct + func NewEnum(name string, values ...string) *Enum + func (e *Enum) AddTo(t *Table, col string) *Col[string] + func (e *Enum) CheckExpr(col string) string + func (e *Enum) Name() string + func (e *Enum) Values() []string + type Event struct + AggregateID string + AggregateType string + CreatedAt time.Time + Headers map[string]string + Offset int64 + Payload json.RawMessage + Type string + Version int64 + type EventInput struct + Headers map[string]string + Payload any + Type string + type EventStore struct + func NewEventStore(db *DB, table string) *EventStore + func (s *EventStore) Append(tx *DB, ctx context.Context, aggregateType, aggregateID string, ...) error + func (s *EventStore) LatestVersion(ctx context.Context, aggregateType, aggregateID string) (int64, error) + func (s *EventStore) Load(ctx context.Context, aggregateType, aggregateID string, fromVersion int64) ([]Event, error) + func (s *EventStore) LoadSnapshot(ctx context.Context, table, aggregateType, aggregateID string) (AggregateSnapshot, bool, error) + func (s *EventStore) SaveSnapshot(ctx context.Context, table string, snap AggregateSnapshot) error + func (s *EventStore) Stream(ctx context.Context, fromOffset int64, limit int) ([]Event, error) + type ExplainPlan struct + Steps []PlanStep + func Explain(db *DB, ctx context.Context, sql string, args ...any) (*ExplainPlan, error) + func (p *ExplainPlan) Fingerprint() string + func (p *ExplainPlan) SeqScans() []string + func (p *ExplainPlan) String() string + func (p *ExplainPlan) UsedIndexes() []string + type Factory struct + func NewFactory[T any](e *Entity[T], template func(seq int) T) *Factory[T] + func (f *Factory[T]) Build() T + func (f *Factory[T]) BuildN(n int) []T + func (f *Factory[T]) Create(ctx context.Context, db *DB) (T, error) + func (f *Factory[T]) CreateN(ctx context.Context, db *DB, n int) ([]T, error) + func (f *Factory[T]) Entity() *Entity[T] + func (f *Factory[T]) Reset() + func (f *Factory[T]) Sequence() int + func (f *Factory[T]) With(mutate func(*T)) *Factory[T] + type GenerateOptions struct + Dir string + FS fs.FS + Name string + NameFn func() string + Now func() int64 + Schema *Schema + WithDown bool + Write func(relPath string, data []byte) error + type GenerateResult struct + DownSQL string + Idx int + Journal []byte + NoOp bool + SQL string + Snapshot []byte + Tag string + func GenerateMigration(opts GenerateOptions) (*GenerateResult, error) + type Guard interface + Predicate func(ctx context.Context) (drops.Expression, error) + func AllOf(guards ...Guard) Guard + func AnyOf(guards ...Guard) Guard + type IdempotencyStore struct + func NewIdempotencyStore(db *DB, table string, ttl time.Duration) *IdempotencyStore + func (s *IdempotencyStore) Cleanup(ctx context.Context) (int64, error) + func (s *IdempotencyStore) Run(ctx context.Context, key string, fn func(tx *DB) ([]byte, error)) ([]byte, error) + func (s *IdempotencyStore) SweepEvery(ctx context.Context, interval time.Duration, onError func(error)) + type InsertHook interface + BeforeInsert func(ctx *InsertHookCtx) + type InsertHookCtx struct + func (c *InsertHookCtx) Has(col *Column) bool + func (c *InsertHookCtx) Set(v ColumnValue) + func (c *InsertHookCtx) SetExpr(col *Column, expr drops.Expression) + type InsertHookFunc func(*InsertHookCtx) + func (f InsertHookFunc) BeforeInsert(ctx *InsertHookCtx) + type JSONPath struct + func JSONField[T any](col ColRef, path ...string) *JSONPath[T] + func (j *JSONPath[T]) Column() *Column + func (j *JSONPath[T]) Eq(v T) drops.Expression + func (j *JSONPath[T]) Gt(v T) drops.Expression + func (j *JSONPath[T]) Gte(v T) drops.Expression + func (j *JSONPath[T]) In(values ...T) drops.Expression + func (j *JSONPath[T]) IsNotNull() drops.Expression + func (j *JSONPath[T]) IsNull() drops.Expression + func (j *JSONPath[T]) Like(pattern string) drops.Expression + func (j *JSONPath[T]) Lt(v T) drops.Expression + func (j *JSONPath[T]) Lte(v T) drops.Expression + func (j *JSONPath[T]) Ne(v T) drops.Expression + func (j *JSONPath[T]) Path() []string + func (j *JSONPath[T]) WriteSQL(b *drops.Builder) + type LoggerFunc = drops.LoggerFunc + type LoggerOptions = drops.LoggerOptions + type MembershipGuard struct + Junction *Table + JunctionResource *Column + JunctionSubject *Column + ResourceOwner *Column + func (g MembershipGuard) Predicate(ctx context.Context) (drops.Expression, error) + type Mixin interface + Apply func(*Table) + type MixinFunc func(*Table) + func (f MixinFunc) Apply(t *Table) + type Money struct + func MoneyFromCents(cents int64) Money + func MoneyFromString(s string) (Money, error) + func MoneyFromUnits(units, cents int64) Money + func MoneyWithExponent(units int64, exponent uint8) Money + func (m *Money) Scan(src any) error + func (m *Money) UnmarshalJSON(b []byte) error + func (m Money) Add(other Money) Money + func (m Money) Cents() int64 + func (m Money) Compare(other Money) int + func (m Money) Exponent() uint8 + func (m Money) IsNegative() bool + func (m Money) IsZero() bool + func (m Money) MarshalJSON() ([]byte, error) + func (m Money) MulInt(n int64) Money + func (m Money) MulRate(rate float64) Money + func (m Money) Neg() Money + func (m Money) String() string + func (m Money) Sub(other Money) Money + func (m Money) Value() (driver.Value, error) + type N1Pattern struct + Count int + SQL string + type N1Report struct + Patterns []N1Pattern + Threshold int + Total int + func (r N1Report) IsClean() bool + type NullsOrdering string + const NullsDefault + const NullsFirst + const NullsLast + type OrderKey struct + Col ColRef + Desc bool + Nulls NullsOrdering + type OrderingColumn struct + func Asc(c ColRef) OrderingColumn + func Desc(c ColRef) OrderingColumn + type Outbox struct + func NewOutbox(db *DB, table string) *Outbox + func (o *Outbox) Cleanup(ctx context.Context, retainAfter time.Duration) (int64, error) + func (o *Outbox) Drain(ctx context.Context, limit int) ([]OutboxEvent, error) + func (o *Outbox) Emit(tx *DB, ctx context.Context, kind string, payload any) error + func (o *Outbox) EmitWith(tx *DB, ctx context.Context, kind string, payload any, opts EmitOptions) error + func (o *Outbox) MarkFailed(ctx context.Context, id int64, attempts int, nextRetryAt time.Time, ...) error + func (o *Outbox) MarkPublished(ctx context.Context, ids ...int64) error + type OutboxBatchHandler func(ctx context.Context, events []OutboxEvent) error + type OutboxEvent struct + AggregateID string + AggregateType string + Attempts int + CreatedAt time.Time + Headers map[string]string + ID int64 + Kind string + LastError string + Payload json.RawMessage + type OutboxHandler func(ctx context.Context, e OutboxEvent) error + type OutboxWorker struct + func NewOutboxWorker(ob *Outbox) *OutboxWorker + func (w *OutboxWorker) OnBatch(fn OutboxBatchHandler) *OutboxWorker + func (w *OutboxWorker) OnError(fn func(error)) *OutboxWorker + func (w *OutboxWorker) OnEvent(fn OutboxHandler) *OutboxWorker + func (w *OutboxWorker) Run(ctx context.Context) error + func (w *OutboxWorker) Tick(ctx context.Context) error + func (w *OutboxWorker) WithBackoff(fn func(attempt int) time.Duration) *OutboxWorker + func (w *OutboxWorker) WithBatch(n int) *OutboxWorker + func (w *OutboxWorker) WithInterval(d time.Duration) *OutboxWorker + func (w *OutboxWorker) WithMaxAttempts(n int) *OutboxWorker + type OwnerGuard struct + Owner *Column + func (g OwnerGuard) Predicate(ctx context.Context) (drops.Expression, error) + type PIIParam struct + Value any + func (p PIIParam) WriteSQL(b *drops.Builder) + type Page struct + HasMore bool + Items []T + NextCursor string + type PageBuilder struct + func (p *PageBuilder[T]) After(cursor string) *PageBuilder[T] + func (p *PageBuilder[T]) All(ctx context.Context) (*Page[T], error) + func (p *PageBuilder[T]) Limit(n int) *PageBuilder[T] + func (p *PageBuilder[T]) OrderBy(cols ...OrderingColumn) *PageBuilder[T] + func (p *PageBuilder[T]) Where(preds ...drops.Expression) *PageBuilder[T] + type PatchOp = ColumnValue + func Dec[T number](col *Col[T], delta T) PatchOp + func Inc[T number](col *Col[T], delta T) PatchOp + func SetIfChanged[T any](col *Col[T], v T) PatchOp + func SetIfGreater[T any](col *Col[T], v T) PatchOp + func SetIfLess[T any](col *Col[T], v T) PatchOp + func Set[T any](col *Col[T], v T) PatchOp + type PlanStep struct + Detail string + ID int64 + Parent int64 + type PushOptions struct + DryRun bool + type PushResult struct + Applied bool + Statements []string + func Push(ctx context.Context, db *DB, schema *Schema, opts ...PushOptions) (*PushResult, error) + type RetryPolicy struct + Backoff func(attempt int) time.Duration + Errors []error + MaxAttempts int + func DefaultRetryPolicy() RetryPolicy + type SafetyOptions struct + Ignore []string + type SafetySeverity int + const SeverityError + const SeverityInfo + const SeverityWarn + func (s SafetySeverity) String() string + type SafetyWarning struct + Message string + Rule string + Severity SafetySeverity + Statement string + Suggestion string + func AnalyzeMigration(sql string, opts ...SafetyOptions) []SafetyWarning + func AnalyzeStatements(stmts []string, opts ...SafetyOptions) []SafetyWarning + type Saga struct + func NewSaga(name string) *Saga + func (s *Saga) Run(db *DB, ctx context.Context, state *SagaState) error + func (s *Saga) Step(name string, forward, compensate SagaStepFn) *Saga + type SagaCompensationFailure struct + Err error + StepIdx int + StepName string + type SagaError struct + Cause error + CompFailures []SagaCompensationFailure + FailedStep string + FailedStepIdx int + SagaName string + func (e *SagaError) Error() string + func (e *SagaError) Unwrap() error + type SagaState struct + func (s *SagaState) Get(key string) (any, bool) + func (s *SagaState) Set(key string, v any) + type SagaStepFn func(ctx context.Context, tx *DB, state *SagaState) error + type Seeder struct + func NewSeeder(db *DB) *Seeder + func SeedAddCreate[T any](s *Seeder, ent *Entity[T], rows ...*T) *Seeder + func SeedAdd[T any](s *Seeder, ent *Entity[T], rows ...T) *Seeder + func SeedDo(s *Seeder, fn func(db *DB, ctx context.Context) error) *Seeder + func (s *Seeder) Apply(ctx context.Context) error + func (s *Seeder) WithoutTransaction() *Seeder type SelectBuilder + func (s *SelectBuilder) AfterCursor(spec CursorSpec, c Cursor) *SelectBuilder + func (s *SelectBuilder) BeforeCursor(spec CursorSpec, c Cursor) *SelectBuilder + func (s *SelectBuilder) OrderByCursor(spec CursorSpec) *SelectBuilder + func (s *SelectBuilder) Unscoped() *SelectBuilder + func (s *SelectBuilder) With(ctes ...*CTE) *SelectBuilder + func (s *SelectBuilder) WithRecursive(ctes ...*CTE) *SelectBuilder + type SoftDeleteCols struct + DeletedAt *Col[time.Time] + func SoftDelete(t *Table) SoftDeleteCols + type SoftDeleteMixin struct + Cols SoftDeleteCols + func (m *SoftDeleteMixin) Apply(t *Table) + type Span interface + End func() + RecordError func(err error) + SetAttribute func(key string, value any) + type TB interface + Cleanup func(fn func()) + Errorf func(format string, args ...any) + Fatalf func(format string, args ...any) + Helper func() + Logf func(format string, args ...any) type Table + func ApplyMixins(t *Table, mixins ...Mixin) *Table + func AutoTable[T any](name string) *Table + func NewAuditTable(name string) *Table + func NewBackfillStateTable(name string) *Table + func NewEventStoreTable(name string) *Table + func NewIdempotencyTable(name string) *Table + func NewOutboxTable(name string) *Table + func NewSnapshotTable(name string) *Table + func (t *Table) DefaultFilter(e drops.Expression) *Table + func (t *Table) DefaultFilters() []drops.Expression + func (t *Table) OnDelete(h DeleteHook) *Table + func (t *Table) OnInsert(h InsertHook) *Table + func (t *Table) OnUpdate(h UpdateHook) *Table + type TimestampsCols struct + CreatedAt *Col[time.Time] + UpdatedAt *Col[time.Time] + func Timestamps(t *Table) TimestampsCols + type TimestampsMixin struct + Cols TimestampsCols + func (m *TimestampsMixin) Apply(t *Table) + type Tracer interface + Start func(ctx context.Context, name string) (context.Context, Span) + type UUIDPrimaryKeyCols struct + ID *Col[string] + func UUIDPrimaryKey(t *Table) UUIDPrimaryKeyCols + type UUIDPrimaryKeyMixin struct + Cols UUIDPrimaryKeyCols + func (m *UUIDPrimaryKeyMixin) Apply(t *Table) type UpdateBuilder + func (u *UpdateBuilder) SetExpr(col *Column, expr drops.Expression) *UpdateBuilder + func (u *UpdateBuilder) Unscoped() *UpdateBuilder + type UpdateHook interface + BeforeUpdate func(ctx *UpdateHookCtx) + type UpdateHookCtx struct + func (c *UpdateHookCtx) Has(col *Column) bool + func (c *UpdateHookCtx) Set(v ColumnValue) + func (c *UpdateHookCtx) SetExpr(col *Column, expr drops.Expression) + type UpdateHookFunc func(*UpdateHookCtx) + func (f UpdateHookFunc) BeforeUpdate(ctx *UpdateHookCtx) + type Window struct + func WindowSpec() *Window + func (w *Window) Frame(spec string) *Window + func (w *Window) OrderBy(exprs ...drops.Expression) *Window + func (w *Window) PartitionBy(exprs ...drops.Expression) *Window v0.4.1 Jul 14, 2026 v0.4.0 Jul 8, 2026 Changes in this version + const DefaultMigrationsTable + var Dialect drops.Dialect = sqliteDialect + var ErrInvalidIdentifier = errors.New("drops/sqlite: invalid identifier") + var ErrNoMigrationsApplied = errors.New("drops/sqlite: no migrations applied") + var ErrNoRows = errors.New("drops/sqlite: no rows in result set") + var ErrNoRowsToInsert = errors.New("drops/sqlite: INSERT with no rows") + var Placeholder = drops.WithDialect(Dialect) + func And(preds ...drops.Expression) drops.Expression + func CreateIndex(name string, t *Table, cols ...ColRef) drops.Expression + func CreateIndexIfNotExists(name string, t *Table, cols ...ColRef) drops.Expression + func CreateTable(t *Table) drops.Expression + func CreateTableIfNotExists(t *Table) drops.Expression + func CreateUniqueIndex(name string, t *Table, cols ...ColRef) drops.Expression + func Diff(prev, cur *Snapshot) []string + func DiffDown(prev, cur *Snapshot) []string + func DropIndex(name string) drops.Expression + func DropIndexIfExists(name string) drops.Expression + func DropTable(t *Table) drops.Expression + func DropTableIfExists(t *Table) drops.Expression + func OnDelete(action string) func(*FK) + func OnUpdate(action string) func(*FK) + func Or(preds ...drops.Expression) drops.Expression + func ParseMigrationName(filename string) (version, name, kind string, ok bool) + func ToSQL(e drops.Expression) (sql string, args []any) + type CheckSnapshot struct + Name string + Value string + type Col struct + func Add[T any](t *Table, c *Col[T]) *Col[T] + func BigInt(name string) *Col[int64] + func BigSerial(name string) *Col[int64] + func Blob(name string) *Col[[]byte] + func Boolean(name string) *Col[bool] + func Bytea(name string) *Col[[]byte] + func Char(name string, _ int) *Col[string] + func Custom[T any](name, typeSQL string) *Col[T] + func Date(name string) *Col[time.Time] + func DoublePrecision(name string) *Col[float64] + func Integer(name string) *Col[int32] + func JSON(name string) *Col[json.RawMessage] + func JSONB(name string) *Col[json.RawMessage] + func Numeric(name string, _, _ int) *Col[string] + func Real(name string) *Col[float32] + func Serial(name string) *Col[int32] + func SmallInt(name string) *Col[int16] + func Text(name string) *Col[string] + func Time(name string) *Col[time.Time] + func Timestamp(name string, _ bool) *Col[time.Time] + func UUID(name string) *Col[string] + func Varchar(name string, _ int) *Col[string] + func (c *Col[T]) AutoIncrement() *Col[T] + func (c *Col[T]) Default(sqlExpr string) *Col[T] + func (c *Col[T]) Eq(v T) drops.Expression + func (c *Col[T]) EqCol(other ColRef) drops.Expression + func (c *Col[T]) Gt(v T) drops.Expression + func (c *Col[T]) Gte(v T) drops.Expression + func (c *Col[T]) In(values ...T) drops.Expression + func (c *Col[T]) IsNotNull() drops.Expression + func (c *Col[T]) IsNull() drops.Expression + func (c *Col[T]) Lt(v T) drops.Expression + func (c *Col[T]) Lte(v T) drops.Expression + func (c *Col[T]) Ne(v T) drops.Expression + func (c *Col[T]) NotNull() *Col[T] + func (c *Col[T]) PrimaryKey() *Col[T] + func (c *Col[T]) References(target *Col[T], opts ...func(*FK)) *Col[T] + func (c *Col[T]) Unique() *Col[T] + func (c *Col[T]) Val(v T) ColumnValue + type ColRef interface + type Column struct + func (c *Column) DefaultSQL() string + func (c *Column) ForeignKey() *FK + func (c *Column) HasDefault() bool + func (c *Column) IsAutoIncrement() bool + func (c *Column) IsNotNull() bool + func (c *Column) IsPrimaryKey() bool + func (c *Column) IsUnique() bool + func (c *Column) Name() string + func (c *Column) Table() *Table + func (c *Column) Type() ColumnType + func (c *Column) WriteSQL(b *drops.Builder) + type ColumnSnapshot struct + AutoIncrement bool + Default *string + Name string + NotNull bool + PrimaryKey bool + Type string + Unique bool + type ColumnType interface + TypeSQL func() string + type ColumnValue interface + type CompositeFK struct + Columns []*Column + Name string + OnDelete string + OnUpdate string + Target *Table + TargetColumns []*Column + type CompositePKSnapshot struct + Columns []string + Name string + type DB struct + func New(drv drops.Driver) *DB + func (db *DB) Begin(ctx context.Context) (*DB, drops.Tx, error) + func (db *DB) Close() error + func (db *DB) Delete(t *Table) *DeleteBuilder + func (db *DB) Driver() drops.Driver + func (db *DB) Exec(ctx context.Context, sql string, args ...any) (drops.Result, error) + func (db *DB) ExecExpr(ctx context.Context, e drops.Expression) (drops.Result, error) + func (db *DB) Find(t *Table) *FindBuilder + func (db *DB) Hook() drops.Hook + func (db *DB) InTx(ctx context.Context, fn func(*DB) error) (err error) + func (db *DB) Insert(t *Table) *InsertBuilder + func (db *DB) Ping(ctx context.Context) error + func (db *DB) Query(ctx context.Context, sql string, args ...any) (drops.Rows, error) + func (db *DB) Select(cols ...drops.Expression) *SelectBuilder + func (db *DB) Update(t *Table) *UpdateBuilder + func (db *DB) WithHook(hook drops.Hook) *DB + type DeleteBuilder struct + func (d *DeleteBuilder) Exec(ctx context.Context) (drops.Result, error) + func (d *DeleteBuilder) ToSQL() (sql string, args []any) + func (d *DeleteBuilder) Where(preds ...drops.Expression) *DeleteBuilder + func (d *DeleteBuilder) WriteSQL(b *drops.Builder) + type Entity struct + func NewEntity[T any](t *Table) *Entity[T] + func (e *Entity[T]) Create(db *DB, ctx context.Context, r *T) error + func (e *Entity[T]) Delete(db *DB, ctx context.Context, id any) (drops.Result, error) + func (e *Entity[T]) Get(db *DB, ctx context.Context, id any) (T, error) + func (e *Entity[T]) PK() *Column + func (e *Entity[T]) Query(db *DB) *EntityQuery[T] + func (e *Entity[T]) Table() *Table + func (e *Entity[T]) Update(db *DB, ctx context.Context, r *T) error + type EntityQuery struct + func (q *EntityQuery[T]) All(ctx context.Context) ([]T, error) + func (q *EntityQuery[T]) Limit(n int64) *EntityQuery[T] + func (q *EntityQuery[T]) Offset(n int64) *EntityQuery[T] + func (q *EntityQuery[T]) One(ctx context.Context) (T, error) + func (q *EntityQuery[T]) OrderBy(exprs ...drops.Expression) *EntityQuery[T] + func (q *EntityQuery[T]) Where(preds ...drops.Expression) *EntityQuery[T] + type FK struct + OnDelete string + OnUpdate string + Target *Column + type FindBuilder struct + func (f *FindBuilder) All(ctx context.Context, dest any) error + func (f *FindBuilder) Limit(n int64) *FindBuilder + func (f *FindBuilder) Offset(n int64) *FindBuilder + func (f *FindBuilder) One(ctx context.Context, dest any) error + func (f *FindBuilder) OrderBy(exprs ...drops.Expression) *FindBuilder + func (f *FindBuilder) Where(preds ...drops.Expression) *FindBuilder + func (f *FindBuilder) With(names ...string) *FindBuilder + type ForeignKeySnapshot struct + ColumnsFrom []string + ColumnsTo []string + Name string + OnDelete string + OnUpdate string + TableFrom string + TableTo string + type InsertBuilder struct + func (i *InsertBuilder) Exec(ctx context.Context) (drops.Result, error) + func (i *InsertBuilder) OrIgnore() *InsertBuilder + func (i *InsertBuilder) OrReplace() *InsertBuilder + func (i *InsertBuilder) Returning(cols ...ColRef) *InsertBuilder + func (i *InsertBuilder) ToSQL() (sql string, args []any) + func (i *InsertBuilder) Values(vals ...ColumnValue) *InsertBuilder + func (i *InsertBuilder) WriteSQL(b *drops.Builder) + type Migration struct + Down func(ctx context.Context, db *DB) error + Name string + Up func(ctx context.Context, db *DB) error + Version string + type MigrationDirection int + const DirectionDown + const DirectionUp + func (d MigrationDirection) String() string + type MigrationHook func(ctx context.Context, tx *DB, mig Migration, dir MigrationDirection) error + type Migrator struct + func NewMigrator(db *DB) *Migrator + func (m *Migrator) Add(mig Migration) *Migrator + func (m *Migrator) AddFS(fsys fs.FS, dir string) error + func (m *Migrator) AddSQL(version, name, upSQL, downSQL string) *Migrator + func (m *Migrator) AfterEach(h MigrationHook) *Migrator + func (m *Migrator) BeforeEach(h MigrationHook) *Migrator + func (m *Migrator) Down(ctx context.Context) error + func (m *Migrator) Status(ctx context.Context) ([]Status, error) + func (m *Migrator) Up(ctx context.Context) error + func (m *Migrator) WithTable(name string) *Migrator + type Relation struct + Foreign *Column + Kind RelationKind + Local *Column + LocalKey *Column + Name string + Target *Table + TargetKey *Column + Through *Table + ThroughForeign *Column + ThroughLocal *Column + type RelationKind int + const BelongsTo + const HasMany + const HasOne + const ManyToMany + type RelationsBuilder struct + func NewRelations(t *Table) *RelationsBuilder + func (b *RelationsBuilder) BelongsTo(name string, target *Table, local, foreign ColRef) *RelationsBuilder + func (b *RelationsBuilder) HasMany(name string, target *Table, local, foreign ColRef) *RelationsBuilder + func (b *RelationsBuilder) HasOne(name string, target *Table, local, foreign ColRef) *RelationsBuilder + func (b *RelationsBuilder) ManyToMany(name string, target, through *Table, ...) *RelationsBuilder + type Schema struct + func NewSchema(tables ...*Table) *Schema + func (s *Schema) Add(t *Table) *Schema + func (s *Schema) Tables() []*Table + type SelectBuilder struct + func (s *SelectBuilder) All(ctx context.Context, dest any) error + func (s *SelectBuilder) Distinct() *SelectBuilder + func (s *SelectBuilder) From(t *Table) *SelectBuilder + func (s *SelectBuilder) Join(t *Table, on drops.Expression) *SelectBuilder + func (s *SelectBuilder) LeftJoin(t *Table, on drops.Expression) *SelectBuilder + func (s *SelectBuilder) Limit(n int64) *SelectBuilder + func (s *SelectBuilder) Offset(n int64) *SelectBuilder + func (s *SelectBuilder) One(ctx context.Context, dest any) error + func (s *SelectBuilder) OrderBy(exprs ...drops.Expression) *SelectBuilder + func (s *SelectBuilder) ToSQL() (sql string, args []any) + func (s *SelectBuilder) Where(preds ...drops.Expression) *SelectBuilder + func (s *SelectBuilder) WriteSQL(b *drops.Builder) + type Snapshot struct + Dialect string + ID string + PrevID string + Tables map[string]*TableSnapshot + Version string + func BuildSnapshot(schema *Schema) *Snapshot + func EmptySnapshot() *Snapshot + func Introspect(ctx context.Context, db *DB) (*Snapshot, error) + func UnmarshalSnapshot(data []byte) (*Snapshot, error) + func (s *Snapshot) Marshal() ([]byte, error) + type Status struct + Applied bool + AppliedAt time.Time + Name string + Version string + type Table struct + func NewTable(name string) *Table + func (t *Table) AddCheck(name, expr string) *Table + func (t *Table) AddUnique(name string, cols ...ColRef) *Table + func (t *Table) Alias() string + func (t *Table) As(alias string) *Table + func (t *Table) Checks() map[string]string + func (t *Table) Col(name string) *Column + func (t *Table) Columns() []*Column + func (t *Table) CompositeForeignKeys() []*CompositeFK + func (t *Table) CompositePrimaryKey() []*Column + func (t *Table) CompositeUniques() map[string][]*Column + func (t *Table) ForeignKey(col, target *Column, opts ...func(*FK)) *Table + func (t *Table) ForeignKeyN(cols []ColRef, target *Table, targetCols []ColRef, opts ...func(*FK)) *Table + func (t *Table) Name() string + func (t *Table) PrimaryKey(cols ...ColRef) *Table + func (t *Table) Relation(name string) *Relation + func (t *Table) WriteSQL(b *drops.Builder) + type TableSnapshot struct + CheckConstraints map[string]*CheckSnapshot + Columns map[string]*ColumnSnapshot + CompositePrimaryKeys map[string]*CompositePKSnapshot + ForeignKeys map[string]*ForeignKeySnapshot + Name string + UniqueConstraints map[string]*UniqueSnapshot + type UniqueSnapshot struct + Columns []string + Name string + type UpdateBuilder struct + func (u *UpdateBuilder) Exec(ctx context.Context) (drops.Result, error) + func (u *UpdateBuilder) Set(vals ...ColumnValue) *UpdateBuilder + func (u *UpdateBuilder) ToSQL() (sql string, args []any) + func (u *UpdateBuilder) Where(preds ...drops.Expression) *UpdateBuilder + func (u *UpdateBuilder) WriteSQL(b *drops.Builder)