lapis
lapis copied to clipboard
Accessing multiple databases?
I have a use case where I may want to access several databases within the same app. I know Lapis isn't designed to do this, is there a quick and dirty hacky way to do it?
What kind of database is this? Is this postgres? Do you need to use models across both databases?
From a high level you minimally need to initialize a new connection to the database on the request, then run queries on it. For performance, you can use the ngx socket pool.
Postgres. I don't strictly need to use models across both, but would prefer it.
I'm open to other solutions as well. My use case is unifying certain kinds of data from multiple applications running on their own domains on a main domain.
I'm considering just making an API for the data I need on each subdomain, and then having the main domain call that API to access the data it needs. Probably less efficient, but I'm guessing more practical.
hi,@Guard13007, I change the lapis source to achieve the feature,here is my hack code: lapis.zip
It works for me