I've an app finished and running locally in wappler (soon live) and now i need to connect the same database under that application to a second app that's being developed also in wappler, with the same technology (node.js and docker) the difference is that this second app doesn't need a database but it needs to retrieve information from the app #1 to be showed in the frontpage.
You can create as many database connections are you're please
If your dockerized database is created via wappler, you will have it available in cloud databases, else, you can alwasy add custom database via url parameters, or refresh your server (from the resource manager, and it will appear on your cloud resource list)
In addition, if database and the application are within the same docker network, container name and port can be used!
Simply add connection in database manager and when selecting Database Query or other database component, simply setect that database as the connection target!
Yes i've created the database via wappler using docker, but it doesn't appears in the cloud services, i've tried to update the resourses but got the same result:
If creating a new database, you should be able to create database as simple as this:
If connecting to existing one, you need to bare one thing in mind, if database is dockerized you HAVE to connect it to the same network as your other project!
Meaning, if your database is within the same stack as application no.1, but the application no.2 is in the different one, it will not connect via localhost. What you need to do is, connect your applciation 2 to the same network as your application no.1 and use db as host and 5432 as port.
You can attach your project to another network via portainer.
My portainer installation failed due to already existing instance running on my system. But once installed you can easily access it via localhost:9000.
There you will ahve to create your account and you can easily manage your containers thereafter.
This applies to a lot of dockerized instances, hency why your database can be easily accessible via database management softwares via 127.0.0.1 and your app can't
That is true for the local environment, but not when the apps are live.
You could always go live with the first app and point to those endpoints for the second app in development, much like you would do for third party API's.
If I'm not mistaken you can now run different Wappler projects at the same time, you just have to use different ports. Were you aware of that possibility?
I have two projects (two wappler apps running on two separate domains) that are connected to one central database. The database is hosted on a remote server, so that it can be accessed independently by both apps in production environment.
Once a database has been setup on a remote server, import the database server under Cloud Providers in Resources Manager, and then select the database cloud server in the database connections to connect.
This is an example of how database connection has been setup in both apps. The connection is using the cloud database and database server that has been imported in the Resources Manager. The database port and credentials will be same in both apps.
I don't see a reason to repeat the API from app #1, it just means having to update twice. That is why I suggested to use the API endpoint for the second app.
Thanks for all the replies, from your suggestions i'll be looking for the best approach for this today.
Hi @ben, that's the idea but my app is offline so i thought the only way around would be connecting to the same database, because i can't access the data return from the #1 if it's offline, i may have to put it online to have access to the endpoints.