Sails + Mysql multi-tenant
Asked Answered
A

1

6

I'm starting a new project and I want to use AngularJS as Frontend and SailsJS as Backend. I have a requirement to separate databases for different clients. So, each client must have its own database.

I didn't find how to make this in Sails and Waterline. Does anybody know how to do this? I have to change schema(or database) in runtime.

Advection answered 20/11, 2014 at 17:7 Comment(5)
As this article of MSDN remarks (msdn.microsoft.com/en-us/library/aa479086.aspx), you have three different approaches while developing a multi-tenant product. Is it absolutely necessary to have separate databases? I am asking because most of the times, by having different schemes it enough (btw, this is how we are handling it). I am asking it, because in that way you don't need to configure several databases, which I think it is possible on Sails.Friesland
Actually, having one schema for each client would be enough. But I think that Sails doesn't support this without customizing and changing its code manually. I didn't find examples about how to do this separation.Advection
That's quite strange. I thought they already had something related to this since it's a usual use case! Anyway, the schema separation approach works good (it depends also a lot of your clients).Friesland
github.com/balderdashy/sails/issues/1857Baring
github.com/balderdashy/waterline/pull/787Baring
S
0

Right now, Sails does not have support for multi tenant databases.

It all depends also how many customers you have.

One approach that you can do (as with any other framework/language) is having (at least) one instance of your application pointing to different database configurations. Then have different domains for each customer. This involves creating a new "domain" per customer.

Another approach (that involves more coding) is to have the concept of an Organization entity that owns every object and include that on every filter.

There has been some PRs in the past about it but didn't move forward.

Storied answered 14/3, 2019 at 15:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.