Documentation
¶
Index ¶
- func NewCardSeeder(db *db.Queries, ctx context.Context, logger logger.LoggerInterface) *cardSeeder
- func NewMerchantSeeder(db *db.Queries, ctx context.Context, logger logger.LoggerInterface) *merchantSeeder
- func NewRoleSeeder(db *db.Queries, ctx context.Context, logger logger.LoggerInterface) *roleSeeder
- func NewSaldoSeeder(db *db.Queries, ctx context.Context, logger logger.LoggerInterface) *saldoSeeder
- func NewTopupSeeder(db *db.Queries, ctx context.Context, logger logger.LoggerInterface) *topupSeeder
- func NewTransactionSeeder(db *db.Queries, ctx context.Context, logger logger.LoggerInterface) *transactionSeeder
- func NewTransferSeeder(db *db.Queries, ctx context.Context, logger logger.LoggerInterface) *transferSeeder
- func NewUserSeeder(db *db.Queries, ctx context.Context, hash hash.HashPassword, ...) *userSeeder
- func NewWithdrawSeeder(db *db.Queries, ctx context.Context, logger logger.LoggerInterface) *withdrawSeeder
- type Deps
- type Seeder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCardSeeder ¶
NewCardSeeder creates a new instance of the cardSeeder, which is responsible for populating the cards table with fake data.
func NewMerchantSeeder ¶
func NewMerchantSeeder(db *db.Queries, ctx context.Context, logger logger.LoggerInterface) *merchantSeeder
NewMerchantSeeder creates a new instance of the merchantSeeder, which is responsible for populating the merchants table with fake data.
Args: db: a pointer to the database queries ctx: a context.Context object logger: a logger.LoggerInterface object
Returns: a pointer to the merchantSeeder struct
func NewRoleSeeder ¶
NewRoleSeeder creates a new instance of the roleSeeder, which is responsible for populating the roles table with fake data.
Args: db: a pointer to the database queries ctx: a context.Context object logger: a logger.LoggerInterface object
Returns: a pointer to the roleSeeder struct
func NewSaldoSeeder ¶
func NewSaldoSeeder(db *db.Queries, ctx context.Context, logger logger.LoggerInterface) *saldoSeeder
NewSaldoSeeder creates a new instance of the saldoSeeder, which is responsible for populating the saldos table with fake data.
Args: db: a pointer to the database queries ctx: a context.Context object logger: a logger.LoggerInterface object
Returns: a pointer to the saldoSeeder struct
func NewTopupSeeder ¶
func NewTopupSeeder(db *db.Queries, ctx context.Context, logger logger.LoggerInterface) *topupSeeder
NewTopupSeeder creates a new instance of the topupSeeder, which is responsible for populating the topups table with fake data.
Args: db: a pointer to the database queries ctx: a context.Context object logger: a logger.LoggerInterface object
Returns: a pointer to the topupSeeder struct
func NewTransactionSeeder ¶
func NewTransactionSeeder(db *db.Queries, ctx context.Context, logger logger.LoggerInterface) *transactionSeeder
NewTransactionSeeder creates a new instance of the transactionSeeder, which is responsible for populating the transactions table with fake data.
Args: db: a pointer to the database queries ctx: a context.Context object logger: a logger.LoggerInterface object
Returns: a pointer to the transactionSeeder struct
func NewTransferSeeder ¶
func NewTransferSeeder(db *db.Queries, ctx context.Context, logger logger.LoggerInterface) *transferSeeder
NewTransferSeeder creates a new instance of the transferSeeder, which is responsible for populating the transfers table with fake data.
Args: db: a pointer to the database queries ctx: a context.Context object logger: a logger.LoggerInterface object
Returns: a pointer to the transferSeeder struct
func NewUserSeeder ¶
func NewUserSeeder(db *db.Queries, ctx context.Context, hash hash.HashPassword, logger logger.LoggerInterface) *userSeeder
NewUserSeeder creates a new instance of the userSeeder, which is responsible for populating the users table with fake data.
Args: db: a pointer to the database queries ctx: a context.Context object hash: a hash.HashPassword object logger: a logger.LoggerInterface object
Returns: a pointer to the userSeeder struct
func NewWithdrawSeeder ¶
func NewWithdrawSeeder(db *db.Queries, ctx context.Context, logger logger.LoggerInterface) *withdrawSeeder
NewWithdrawSeeder creates a new instance of the withdrawSeeder, which is responsible for populating the withdraws table with fake data.
Args: db: a pointer to the database queries ctx: a context.Context object logger: a logger.LoggerInterface object
Returns: a pointer to the withdrawSeeder struct
Types ¶
type Deps ¶
type Deps struct {
DB *db.Queries
Hash hash.HashPassword
Ctx context.Context
Logger logger.LoggerInterface
}
Deps is a struct that contains the dependencies for the seeder
type Seeder ¶
type Seeder struct {
User *userSeeder
Role *roleSeeder
Saldo *saldoSeeder
Topup *topupSeeder
Withdraw *withdrawSeeder
Transfer *transferSeeder
Merchant *merchantSeeder
Card *cardSeeder
Transaction *transactionSeeder
}
Seeder is a struct that contains all the seeders
func NewSeeder ¶
NewSeeder initializes and returns the Seeder.
It takes a Deps struct which contains the required dependencies to initialize the Seeder.
The returned Seeder contains the following: - User: the user seeder - Role: the role seeder - Saldo: the saldo seeder - Topup: the topup seeder - Withdraw: the withdraw seeder - Transfer: the transfer seeder - Merchant: the merchant seeder - Card: the card seeder - Transaction: the transaction seeder
func (*Seeder) Run ¶
Run runs all the seeders in sequence with a delay of 30 seconds between each seeder.
It calls the Seed method of each seeder in the following order:
1. User 2. Role 3. Card 4. Saldo 5. Topup 6. Withdraw 7. Transfer 8. Merchant 9. Transaction
If any of the seeders fail, the function returns an error.
Returns: an error if any of the seeders fail, otherwise nil