Documentation ¶
Overview ¶
Package sql implements the SQL storage layer.
Index ¶
- Constants
- func Get[T any](ctx context.Context, querier Querier, query *sqlf.Query) (T, error)
- func Migrate(dsn string) error
- func Select[T any](ctx context.Context, querier Querier, query *sqlf.Query) ([]T, error)
- type AccountStore
- func (s *AccountStore) ByID(ctx context.Context, id ulid.ULID) (a database.Account, err error)
- func (s *AccountStore) ByUsername(ctx context.Context, username string) (a database.Account, err error)
- func (s *AccountStore) Create(ctx context.Context, username, email string, password []byte) (a database.Account, err error)
- type Base
- type BlogStore
- func (s *BlogStore) ByID(ctx context.Context, id ulid.ULID) (b database.Blog, err error)
- func (s *BlogStore) ByName(ctx context.Context, name, domain string) (b database.Blog, err error)
- func (s *BlogStore) CreateLocal(ctx context.Context, accountID ulid.ULID, name string) (b database.Blog, err error)
- func (s *BlogStore) LocalCount(ctx context.Context) (count int64, err error)
- type PostStore
- type Querier
- type ReleaseableQuerier
- type Tx
Constants ¶
View Source
const ( ErrRemoteBlog = errors.Sentinel("blog is remote") ErrUsernameTaken = errors.Sentinel("username or blog name is taken") ErrNotFound = errors.Sentinel("not found") )
View Source
const PasswordCost = 15
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccountStore ¶
type AccountStore struct {
// contains filtered or unexported fields
}
AccountStore is the interface to accounts in the database.
func NewAccountStore ¶
func NewAccountStore(q Querier) *AccountStore
NewAccountStore creates a new AccountStore instance.
func (*AccountStore) ByUsername ¶
func (s *AccountStore) ByUsername(ctx context.Context, username string) (a database.Account, err error)
ByUsername gets an account by its username.
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
Base is the base database pool used by storage layers.
func (*Base) Acquire ¶
func (base *Base) Acquire(ctx context.Context) (ReleaseableQuerier, error)
Acquire acquires a connection from the database pool. It is the caller's responsibility to call the Release method.
func (*Base) PoolQuerier ¶
type BlogStore ¶
type BlogStore struct {
// contains filtered or unexported fields
}
BlogStore is the interface to blogs in the database.
func NewBlogStore ¶
NewBlogStore creates a new BlogStore instance.
type PostStore ¶
type PostStore struct {
// contains filtered or unexported fields
}
PostStore is the interface to posts in the database.
func NewPostStore ¶
NewPostStore creates a new PostStore instance.
type ReleaseableQuerier ¶
type ReleaseableQuerier interface { Querier Release() }
Click to show internal directories.
Click to hide internal directories.