Nuxt & Mikro-ORM
Hi everyone! 👋
I’m currently trying to implement Nuxt with Mikro-ORM, but I haven’t had much success yet. Has anyone here successfully implemented this combination? If so, I’d really appreciate it if you could share how you did it or point me in the right direction. Thanks so much!
7 Replies
Hi @Ranma. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I apologize, but I don't have any specific information about implementing Mikro-ORM with Nuxt in the provided knowledge sources. The documents don't contain details about integrating Mikro-ORM with Nuxt.
However, I can provide some general guidance based on Nuxt's architecture:
1. You would likely need to create a Nuxt module to integrate Mikro-ORM, similar to how other database integrations are done.
2. The integration would probably involve setting up Mikro-ORM in the server-side part of your Nuxt application.
3. You may need to configure Mikro-ORM in your
nuxt.config.ts
file.
For more specific help, I'd recommend:
1. Checking the official Mikro-ORM documentation for any Nuxt-specific integration guides.
2. Looking for community-created modules or examples on GitHub.
3. Asking in the Nuxt community discussions for more targeted assistance.
If you're open to alternative ORMs, Nuxt does have some built-in support for other database solutions. For example, there's a recipe for using Drizzle ORM in the Nuxt documentation, which might be easier to implement.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@200321903448162305> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
GitHub
Nuxt 3 nitro + mikro-orm · Issue #5603 · nuxt/framework
Environment Operating System: Linux Node Version: v16.15.1 Nuxt Version: 3.0.0-rc.4 Package Manager: [email protected] Builder: vite User Config: - Runtime Modules: - Build Modules: - Reproduction import ...
And now you can use
RequestContext.enter(this.orm.em);
as mikro-orm docs say suitable for elysia style middlewares without a next
like h3 if you not use something like app.use(fromNodeListener(exampleMiddleware())); something like
Use or look at code of that module https://github.com/boenrobot/nuxt-mikro-orm-module
GitHub
GitHub - boenrobot/nuxt-mikro-orm-module: A module to use MikroORM ...
A module to use MikroORM inside Nuxt applications. Contribute to boenrobot/nuxt-mikro-orm-module development by creating an account on GitHub.
@Mittchel Thank you! I found the articles you mentioned and was stuck at importing the entities. I found a solution by setting the entities in the config file as follows:
By doing this there is no need for an extra module
oh yes, I forgot to mention that