Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loopback rest-crud models to multiple datasources #5581

Closed
fubz opened this issue May 27, 2020 · 3 comments
Closed

Loopback rest-crud models to multiple datasources #5581

fubz opened this issue May 27, 2020 · 3 comments
Assignees
Labels

Comments

@fubz
Copy link

fubz commented May 27, 2020

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:

  1. 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.

  2. 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.

@raymondfeng
Copy link
Contributor

@fubz
Copy link
Author

fubz commented May 27, 2020

I did check out the multi-tenancy project. It looked promising at first however it looks like this isn't my use case. multi-tenancy in my understanding is having multiple users, having shared access to a singular database. I need to have 1 user, connect to 1 loopback, that updates and joins data to and from multiple - but same schema - databases.

@stale
Copy link

stale bot commented Dec 25, 2020

This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository. This issue will be closed within 30 days of being stale.

@stale stale bot added the stale label Dec 25, 2020
@bajtos bajtos closed this as completed Mar 11, 2021
@loopbackio loopbackio locked and limited conversation to collaborators Mar 11, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

4 participants