makeless / makeless-go

[BETA] Makeless - SaaS Framework - Golang Implementation
https://github.com/makeless
Other
88 stars 12 forks source link

Question - Database Context #24

Open WildEgo opened 3 years ago

WildEgo commented 3 years ago

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

Thank in advance!

loeffel-io commented 3 years ago

Hey @WildEgo,

could you please provide more infos

Thanks!

WildEgo commented 3 years ago

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

loeffel-io commented 3 years ago

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)

WildEgo commented 3 years ago

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

loeffel-io commented 3 years ago

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

WildEgo commented 3 years ago

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