Replies: 3 comments 1 reply
-
I believe that the entire lucid Database changed, but there is no documentation, there is only db.connection().query, in the ORM there is nothing about it and there is no longer any exchange method. |
Beta Was this translation helpful? Give feedback.
-
This is the only information about, but nothing about, the Orm model, and overall |
Beta Was this translation helpful? Give feedback.
-
Solution Instead of using Database.connection as in v5, use BaseModel.connection, the documentation says not to use it, but for the dynamic case it would be correct, right? In my case, I change databases according to the url parameter, but I couldn't do the same with "db", I did one for each one. |
Beta Was this translation helpful? Give feedback.
-
In AdonisJS 6, I'm trying to dynamically change the database connection for a Lucid ORM model based on incoming requests. In previous versions, I could easily switch the connection directly on the model instance using useConnection(params.db_sm).all(). However, this method is no longer available in AdonisJS 6.
I've tried using Database.connection(), Database.use() or Database.call(), but they don't seem to work for switching connections globally and dynamically like before. Could someone please clarify how to achieve dynamic and global connection switching in AdonisJS 6? For example, how can I change the connection based on a request received in a middleware?
Thank you for your help!
Beta Was this translation helpful? Give feedback.
All reactions