Documentation
¶
Overview ¶
Package seed provides helpers for seeding test and development data.
The package is intended for non-production use (tests, local development).
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidCount is returned when a count argument is less than or equal to zero. ErrInvalidCount = errors.New("count must be greater than zero") // ErrNoRows indicates that a query or operation returned no rows. ErrNoRows = errors.New("no rows") )
Functions ¶
This section is empty.
Types ¶
type Seed ¶
type Seed struct {
// contains filtered or unexported fields
}
Seed holds dependencies required by Seed methods.
func (*Seed) Books ¶
Books seeds the database with `count` random books.
It generates a unique public slug (entities.public_id) for each book title, creates and persists a cover image file, then creates an entity + book record. Inserts are executed concurrently; the first error stops the seeding.
func (*Seed) RandomUserID ¶
RandomUserID returns a random user ID.
On the first call, it loads up to 100 random user IDs from the database and caches them for subsequent calls to avoid repeated queries.
Click to show internal directories.
Click to hide internal directories.