DEV Community

Discussion on: How do you handle the data ownership of a multi-tenant product?

Collapse
 
muthandir profile image
muthandir • Edited

I'll go first. So I have this SAAS project, I use node.js and I want to use sequelize for the ORM solution. But I don't want to expose the concrete ORM selection to my colleagues. So I created an NPM package, which internally uses sequelize and exposes sql manipulation functionalities using sequlize as an internal dependency. This library injects customer_id in all type of sql statements sequelize creates. Something like:
select * from products where user_id=3 and customer_id=4 <= customer_id gets inserted by our in-house library.
or insert into products (x,y,z, customer_id) values (1,2,3,4)<= customer_id added by our in-house library
or update products set x=y where id=xyz and customer_id=4 <= customer_id added by our in-house library
Note: This is a fairly simplified summary of what the library does.