This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Loopback rest-crud models to multiple datasources #5581
Labels
You can continue the conversation there. Go to discussion →
Hello all,
I have a particular use case that I am trying to solve and based on a conversation I had with @raymondfeng at IBM Think in 2019, Loopback 4 should have the features required to solve my problem case.
I have an application that is Active/Active in multiple data centers and I need my Loopback application to handle updating an Oracle database in both data centers as well as combining and deduplicating when requesting data from these multiple databases.
Let's go over some use cases:
User is updating a configuration that needs to be posted to and the same in both data centers. User fills out form, presses Save, data posts to Loopback. Loopback then needs to insert/update to both back end data sources.
User is viewing log data. User requests Log model from Loopback, pulls data from both data centers, performs a union (and possibly a deepEquals) and presents user with data from both data centers.
That should cover all my cases. When fetching data, if I always unionWith a deep equals, then I will be able to display config data without it being duplicated, as the configurations should be the same in both data centers. Then when the app is fetching data that is unique to the data center, such as a log, a union with a deep equals will combine the data into an aggregate view.
There are certainly the error cases, what happens when 1 data center is down? I imagined persisting the insert/update in another table which could then be acted upon when the downed data center returns.
I believe this topic aligns a little bit with the issue: Multi-tenancy and dynamic schema selection, in particular StackOverflow answer: How to attach a single model (e.g. Product) to multiple datasources (LB3)
I just recently started using Loopback 4, and recreated my app that existed as a Loopback 3 app, using the @loopback/rest-crud component. I was hoping to leverage some of the magic from the rest-crud project, but I suppose this might be a case where I need dig deeper into Loopback 4 features. But I figured I would start with the experts in case I am missing an obvious avenue to approach.
The text was updated successfully, but these errors were encountered: