fix: template
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
|||||||
func CommandGenEnum(root *cobra.Command) {
|
func CommandGenEnum(root *cobra.Command) {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "enum",
|
Use: "enum",
|
||||||
|
Aliases: []string{"e"},
|
||||||
Short: "Generate enums",
|
Short: "Generate enums",
|
||||||
RunE: commandGenEnumE,
|
RunE: commandGenEnumE,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
func CommandGenModel(root *cobra.Command) {
|
func CommandGenModel(root *cobra.Command) {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "model",
|
Use: "model",
|
||||||
|
Aliases: []string{"m"},
|
||||||
Short: "Generate jet models",
|
Short: "Generate jet models",
|
||||||
RunE: commandGenModelE,
|
RunE: commandGenModelE,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ func getTypePkgName(typ string) string {
|
|||||||
func CommandGenProvider(root *cobra.Command) {
|
func CommandGenProvider(root *cobra.Command) {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "provider",
|
Use: "provider",
|
||||||
|
Aliases: []string{"p"},
|
||||||
Short: "Generate providers",
|
Short: "Generate providers",
|
||||||
Long: `
|
Long: `
|
||||||
// @provider
|
// @provider
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import (
|
|||||||
func CommandMigrate(root *cobra.Command) {
|
func CommandMigrate(root *cobra.Command) {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "migrate [up|up-by-one|up-to|create|down|down-to|fix|redo|reset|status|version]",
|
Use: "migrate [up|up-by-one|up-to|create|down|down-to|fix|redo|reset|status|version]",
|
||||||
|
Aliases: []string{"m"},
|
||||||
RunE: commandMigrate,
|
RunE: commandMigrate,
|
||||||
}
|
}
|
||||||
cmd.Flags().StringP("config", "c", "config.toml", "database config file")
|
cmd.Flags().StringP("config", "c", "config.toml", "database config file")
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import (
|
|||||||
func CommandNewModule(root *cobra.Command) {
|
func CommandNewModule(root *cobra.Command) {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "module",
|
Use: "module",
|
||||||
|
Aliases: []string{"m"},
|
||||||
Short: "new module",
|
Short: "new module",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
RunE: commandNewModuleE,
|
RunE: commandNewModuleE,
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ func isValidGoPackageName(name string) bool {
|
|||||||
func CommandNewProject(root *cobra.Command) {
|
func CommandNewProject(root *cobra.Command) {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "project",
|
Use: "project",
|
||||||
|
Aliases: []string{"p"},
|
||||||
Short: "new project",
|
Short: "new project",
|
||||||
RunE: commandNewProjectE,
|
RunE: commandNewProjectE,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"{{.ModuleName}}/pkg/consts"
|
|
||||||
|
|
||||||
"github.com/go-jet/jet/v2/qrm"
|
"github.com/go-jet/jet/v2/qrm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const CtxDB = "__db__tx:"
|
||||||
|
|
||||||
func FromContext(ctx context.Context, db *sql.DB) qrm.DB {
|
func FromContext(ctx context.Context, db *sql.DB) qrm.DB {
|
||||||
if tx, ok := ctx.Value(consts.CtxKeyTx).(*sql.Tx); ok {
|
if tx, ok := ctx.Value(CtxDB).(*sql.Tx); ok {
|
||||||
return tx
|
return tx
|
||||||
}
|
}
|
||||||
return db
|
return db
|
||||||
|
|||||||
Reference in New Issue
Block a user