meanio icon indicating copy to clipboard operation
meanio copied to clipboard

How to use multiple db connections?

Open pratik60 opened this issue 11 years ago • 5 comments

I believe we have already deployed a way on how to use multiple db connections in the meanio 0.4.1 branch. But I have no idea on how to use the same.

Can you reply here or add to the docs?

My particular use case has me needing the db connection based on the client (subdomain in this case). Any suggestions here would be great.

pratik60 avatar Nov 17 '14 09:11 pratik60

@veljkopopovic , @andrija-hers maybe you can post a gist with how to utilize the multiple mongo connection db stuff - for people like @pratik60 and his team that wish to work on muli-tennency

liorkesos avatar Nov 18 '14 06:11 liorkesos

Will do, we've been in a rush these days, but I hope I will manage to post something usefull about it till weekend ... On 18 Nov 2014 07:23, "Lior Kesos" [email protected] wrote:

@veljkopopovic https://github.com/veljkopopovic , @andrija-hers https://github.com/andrija-hers maybe you can post a gist with how to utilize the multiple mongo connection db stuff - for people like @pratik60 https://github.com/pratik60 and his team that wish to work on muli-tennency

— Reply to this email directly or view it on GitHub https://github.com/linnovate/meanio/issues/21#issuecomment-63427897.

veljkopopovic avatar Nov 18 '14 08:11 veljkopopovic

So, I'm digging into the DB code at the moment. The disconnect I'm having is that the primary pattern for packages is var mongoose = require('mongoose'); mongoose.model('ModelName', SchemaObject)

This seems to stem from MeanIO just automatically including any file in the models folder. We're making the database object accessible by MeanIO but at the same time the mongoose object from require is just as valid in a single database environment.

Considering always using the multi database concept, and if there only happens to be one connection that's fine. However, it may break older packages.

Maybe it's a point of transition to a new MeanIO version? I'd rather get a single approach working well, than multiple approaches having to bend to work with each other.

clowenhg avatar Jul 30 '16 18:07 clowenhg

@pratik60 did you ever figure this out?

timelf123 avatar Aug 23 '16 17:08 timelf123

@timelf123 : https://github.com/linnovate/mean/wiki/Database-core-module was this of any help? I haven't been in meanio code for a loooong time ago ... If I find some time this evening, I will download mean stack and give it a try ...

veljkopopovic avatar Aug 24 '16 09:08 veljkopopovic