makeless-go icon indicating copy to clipboard operation
makeless-go copied to clipboard

Question - Database Context

Open WildEgo opened this issue 4 years ago • 6 comments

Hey guys was looking at this and seemed interesting, I was wondering can I change the database context on the fly?

Thank in advance!

WildEgo avatar Sep 20 '21 17:09 WildEgo

Hey @WildEgo,

could you please provide more infos

Thanks!

loeffel-io avatar Sep 20 '21 19:09 loeffel-io

I'm thinking of playing with this SaaS framework so I was wondering, can I change the database connection on the fly, for example one request has Conn1 and the other has a Conn2, they connect thru a middleware and the data should be accessible on the resolver

WildEgo avatar Sep 20 '21 19:09 WildEgo

Yes, that's possible!

You can just use the gorm plugin https://github.com/go-gorm/dbresolver or multiple db instances on a Acme struct (highly recommended)

loeffel-io avatar Sep 20 '21 20:09 loeffel-io

Yes, that's possible!

You can just use the gorm plugin https://github.com/go-gorm/dbresolver or multiple db instances on a Acme struct

Thank you for the quick reply, I've looked a bit into DBResolver and it looked like it couldn't really do it since I got the data in the runtime, I've never tried that last one could you send me a couple of links? I was trying at the moment by running the connect function again but it got overwritten at the time it got to the resolver

WildEgo avatar Sep 20 '21 20:09 WildEgo

I am currently at vacation! I will update the demo on next Monday because multiple people got stuck at this point

loeffel-io avatar Sep 20 '21 21:09 loeffel-io

I am currently at vacation! I will update the demo on next Monday because multiple people got stuck at this point

Thank you mate I didn't know, take ur time and enjoy ur vacation, thank u for this library, I've been going thru it and learning more GO thanks to it, truly appreciate ur work

WildEgo avatar Sep 20 '21 21:09 WildEgo