Add an admin command for listing newsletter emails

This commit is contained in:
Ben Visness 2024-07-06 16:16:26 -05:00
parent 86b87b2ec8
commit 4b26a92018
2 changed files with 20 additions and 0 deletions

View File

@ -620,5 +620,20 @@ func init() {
}
adminCommand.AddCommand(uploadAsset)
adminCommand.AddCommand(&cobra.Command{
Use: "newsletteremails",
Short: "Print a list of all newsletter email receipients",
Run: func(cmd *cobra.Command, args []string) {
ctx := context.Background()
conn := db.NewConn()
defer conn.Close(ctx)
recipients := utils.Must1(db.Query[models.NewsletterEmail](ctx, conn, `SELECT $columns FROM newsletter_emails`))
for _, r := range recipients {
fmt.Println(r.Email)
}
},
})
addProjectCommands(adminCommand)
}

View File

@ -0,0 +1,5 @@
package models
type NewsletterEmail struct {
Email string `db:"email"`
}