db

package
v0.16.6 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MigrationsFS embed.FS

MigrationsFS holds Atlas migration files. Embed the entire directory so it works even when no migrations exist yet.

Functions

func ConfigureDB added in v0.8.0

func ConfigureDB(db *sql.DB) error

ConfigureDB enables the SQLite connection policy Anna relies on. Connection-level pragmas are safe here because OpenDB constrains each handle to a single long-lived underlying connection.

func OpenDB

func OpenDB(dbPath string) (*sql.DB, error)

OpenDB opens a SQLite database at the given path, configures it (WAL mode, foreign keys, busy timeout) and runs migrations. The parent directory is created if it doesn't exist.

Types

type AuthStore added in v0.9.0

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

AuthStore implements auth.AuthStore using sqlc queries backed by SQLite.

func NewAuthStore added in v0.9.0

func NewAuthStore(db *sql.DB) *AuthStore

NewAuthStore creates a new AuthStore wrapping the given database connection.

func (*AuthStore) AssignAgent added in v0.9.0

func (s *AuthStore) AssignAgent(ctx context.Context, userID int64, agentID string) error

func (*AuthStore) CountUsers added in v0.9.0

func (s *AuthStore) CountUsers(ctx context.Context) (int64, error)

func (*AuthStore) CreateIdentity added in v0.9.0

func (s *AuthStore) CreateIdentity(ctx context.Context, i auth.Identity) (auth.Identity, error)

func (*AuthStore) CreatePolicy added in v0.9.0

func (s *AuthStore) CreatePolicy(ctx context.Context, p auth.Policy) (auth.Policy, error)

func (*AuthStore) CreateSession added in v0.9.0

func (s *AuthStore) CreateSession(ctx context.Context, sess auth.Session) (auth.Session, error)

func (*AuthStore) CreateUser added in v0.9.0

func (s *AuthStore) CreateUser(ctx context.Context, username, passwordHash string) (auth.AuthUser, error)

func (*AuthStore) DeleteExpiredSessions added in v0.9.0

func (s *AuthStore) DeleteExpiredSessions(ctx context.Context) error

func (*AuthStore) DeleteIdentity added in v0.9.0

func (s *AuthStore) DeleteIdentity(ctx context.Context, id int64) error

func (*AuthStore) DeletePolicy added in v0.9.0

func (s *AuthStore) DeletePolicy(ctx context.Context, id string) error

func (*AuthStore) DeleteSession added in v0.9.0

func (s *AuthStore) DeleteSession(ctx context.Context, id string) error

func (*AuthStore) DeleteUser added in v0.9.0

func (s *AuthStore) DeleteUser(ctx context.Context, id int64) error

func (*AuthStore) DeleteUserSessions added in v0.9.0

func (s *AuthStore) DeleteUserSessions(ctx context.Context, userID int64) error

func (*AuthStore) GetIdentity added in v0.9.0

func (s *AuthStore) GetIdentity(ctx context.Context, id int64) (auth.Identity, error)

func (*AuthStore) GetIdentityByPlatform added in v0.9.0

func (s *AuthStore) GetIdentityByPlatform(ctx context.Context, platform, externalID string) (auth.Identity, error)

func (*AuthStore) GetPolicy added in v0.9.0

func (s *AuthStore) GetPolicy(ctx context.Context, id string) (auth.Policy, error)

func (*AuthStore) GetSession added in v0.9.0

func (s *AuthStore) GetSession(ctx context.Context, id string) (auth.Session, error)

func (*AuthStore) GetUser added in v0.9.0

func (s *AuthStore) GetUser(ctx context.Context, id int64) (auth.AuthUser, error)

func (*AuthStore) GetUserByUsername added in v0.9.0

func (s *AuthStore) GetUserByUsername(ctx context.Context, username string) (auth.AuthUser, error)

func (*AuthStore) ListAgentUserIDs added in v0.9.0

func (s *AuthStore) ListAgentUserIDs(ctx context.Context, agentID string) ([]int64, error)

func (*AuthStore) ListEnabledPolicies added in v0.9.0

func (s *AuthStore) ListEnabledPolicies(ctx context.Context) ([]auth.Policy, error)

func (*AuthStore) ListIdentitiesByUser added in v0.9.0

func (s *AuthStore) ListIdentitiesByUser(ctx context.Context, userID int64) ([]auth.Identity, error)

func (*AuthStore) ListPolicies added in v0.9.0

func (s *AuthStore) ListPolicies(ctx context.Context) ([]auth.Policy, error)

func (*AuthStore) ListUserAgentIDs added in v0.9.0

func (s *AuthStore) ListUserAgentIDs(ctx context.Context, userID int64) ([]string, error)

func (*AuthStore) ListUsers added in v0.9.0

func (s *AuthStore) ListUsers(ctx context.Context) ([]auth.AuthUser, error)

func (*AuthStore) RemoveAgent added in v0.9.0

func (s *AuthStore) RemoveAgent(ctx context.Context, userID int64, agentID string) error

func (*AuthStore) UpdateIdentityExternalID added in v0.10.0

func (s *AuthStore) UpdateIdentityExternalID(ctx context.Context, id int64, externalID string) error

func (*AuthStore) UpdatePolicy added in v0.9.0

func (s *AuthStore) UpdatePolicy(ctx context.Context, p auth.Policy) error

func (*AuthStore) UpdateSessionExpiry added in v0.9.0

func (s *AuthStore) UpdateSessionExpiry(ctx context.Context, id string, expiresAt time.Time) error

func (*AuthStore) UpdateUser added in v0.9.0

func (s *AuthStore) UpdateUser(ctx context.Context, u auth.AuthUser) error

func (*AuthStore) UpdateUserAgeKeys added in v0.15.0

func (s *AuthStore) UpdateUserAgeKeys(ctx context.Context, userID int64, publicKey, privateKey string) error

func (*AuthStore) UpdateUserDefaultAgent added in v0.9.0

func (s *AuthStore) UpdateUserDefaultAgent(ctx context.Context, userID int64, agentID string) error

func (*AuthStore) UpdateUserNotifyIdentity added in v0.9.0

func (s *AuthStore) UpdateUserNotifyIdentity(ctx context.Context, userID int64, identityID *int64) error

func (*AuthStore) UpdateUserRole added in v0.9.0

func (s *AuthStore) UpdateUserRole(ctx context.Context, userID int64, role string) error

Jump to

Keyboard shortcuts

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