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.

Travis Webb
  • 14,688
  • 7
  • 55
  • 109
Clayton Kuhn
  • 71
  • 1
  • 4
  • As this article of MSDN remarks (http://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. – facundofarias Nov 20 '14 at 17:12
  • 1
    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. – Clayton Kuhn Nov 20 '14 at 17:19
  • 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). – facundofarias Nov 20 '14 at 17:21
  • https://github.com/balderdashy/sails/issues/1857 – Meeker Jan 16 '15 at 17:41
  • https://github.com/balderdashy/waterline/pull/787 – Meeker Jan 29 '15 at 15:15

1 Answers1

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.

Luis Lobo Borobia
  • 994
  • 11
  • 25