Skip to content

🟠 MongoDB not supported end-to-end: DI container is GORM-shaped (NewPostgres…/*gorm.DB) #55

Description

@sazardev

Severity: 🟠 HIGH — --database mongodb does not compile end-to-end

After the 1.25.x fixes, a MongoDB project's main.go and repository now compile, but the DI container is generated GORM-shaped and breaks the build.

Reproduction

goca init m --module github.com/test/m --database mongodb
cd m
goca feature Item --fields "name:string,qty:int"
goca integrate --all
go build ./...

Actual

internal/di/container.go: undefined: repository.NewPostgresItemRepository

internal/di/container.go is generated with db *gorm.DB, NewContainer(db *gorm.DB) and repository.NewPostgresItemRepository(c.db), but the MongoDB repository constructor is NewMongoItemRepository(db *mongo.Database), and the Mongo main.go exposes a mongoClient *mongo.Client, not a *gorm.DB.

Expected

For mongodb, the DI container should:

  • take a *mongo.Database (derived from the mongoClient),
  • call repository.NewMongo<Entity>Repository(...),
  • and be wired into the Mongo main.go.

Notes / current state

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions