How to make a lookup in different databases using nestjs and mongoose? - mongodb

I would like to ask if it's possible to make a lookup to a different databases using nestjs and mongodb.
I know how to make connections to different databases and naming them, but this is not the case, because the connections are working separately. I want to make a lookup which is looking for the different connections at the same time. It's possible in express for sure so I suppose it has to be possible in nestjs too. Thanks for any help!

Related

How to connect to PostgreSQL with different users and different privileges

I have created a Flask application using SQLAlchemy as the ORM. I also use flask-login to manage my different users. I want to connect to a PostgreSQL database with different flask users that correspond to different postgres users that have different privileges.
They should be able to be logged in at the same time and make different queries with their individual rights. I tried all kinds of pooling methods by SQLAlchemy, but could not manage to achieve what I want. It always led to an arbitrary association of the open connections to the different users. What is the best way to do this, i.e. to achieve this kind of "session-persistent" database connection behaviour?
Thanks in advance for any help!

How to connect Apollographql to multiple Postgres databases

I would like to use Apollographql to connect multiple Postgres databases which share the same structures (tables, columns). The idea was having a single endpoint to access any of these databases (using namespaces), but I couldn't find in the documentation how to do this.
I need a bit of your wisdom guys, how can Apollo connect to multiple Postgres databases using different namespaces? Is there another app better suited for this kind of requirements?

Can you connect to two postgres databases in Springboot?

If yes, how?
I am writing a archival project where old data from one database has to be moved to another. For this, I need to connect to two database in a springboot project.
Any pointers would be appreciated.
You need to provide two different DataSources (two different beans).
Take a look at http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-two-datasources

Multiple server instance load and database balancing

Please correct me if I am wrong but I guess handling more requests and load by adding more machines or balancing the load between multiple servers is horizontal scaling. So, if I add more servers, how do I distribute the database? Do I create only one database to hold the user records with multiple servers? Or do I split the database too? Then what about database integrity? How to synchronize it? I am a newbie and really confused but eager to learn. I would like to use postgresql for my project and would like to know some basic things before I start. What I want to do is, create two servers for the application load balancing (please correct me if its not what I have to do). How will I manage the database across these without database integrity? Do I have to replicate the data within the two servers? How do you guyz have multiple instance and manage database? Do I need to go through sharding for this? What would be the best approach to have many instance without database integrity in accordance to postgresql. I would really appreciate if anyone could explain it to me. Thank you!
Not sure if you are looking just for a service, which could bring you what you need so you don't have to spend time on it, or if on the other hand, you would like to implement that on your end, which I guess could be quite complex.
If you are looking for your own solution, maybe you should take a look at Postgres-XC, which is a group that provides a database cluster based upon PostgreSQL database.
On the other hand, if you are just interested in the development process and don't want to spend time on this when you can have it on the cloud, maybe you would like to take a look at EnterpriseDB which provides PostgreSQL on the cloud.
For your application, you can also use a cloud service in which you can even auto-scale your app depending on some parameters as it is explained here.

Using EF with different read and write db servers

I’m considering using Entity Framework for a project. I’m trying to understand how I can configure EF to work with a database environment that is configured with a read server and a write server.
All updates to the write server will be replicated over to the read servers.
My questions are:
Do I need to generate different data models for the two environments?
Can I reuse the same data model?
Is there something built into EF itself that will allow for this?
Thanks
You can reuse the same model because you can instantiate an ObjectContext with any connection string you like. AFAIK you can even switch out the connection later, so you can use two different server connections with the same EntityContext.
If the data models are identical, then no.
Du to #1 being no, #2 is automatically yes.
EF just requires you pass it a different connection string
However...
I'm not really sure how you intend to make this work. You will lose virtually benefit of an ORM, you can't do change tracking, and you will have a lot of problems not reading from the write model.
Frankly, I'm not sure how you could make this work with any ORM.