express-mongo-crud | Express middleware for mongo crud APIs | Runtime Evironment library
kandi X-RAY | express-mongo-crud Summary
kandi X-RAY | express-mongo-crud Summary
Express middleware for mongo crud APIs
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of express-mongo-crud
express-mongo-crud Key Features
express-mongo-crud Examples and Code Snippets
Community Discussions
Trending Discussions on express-mongo-crud
QUESTION
I have a container based application running node JS and my backend is a mongoDB container.
Basically, what I am planning to do is to run this in kubernetes.
I have deployed this as separate containers on my current environment and it works fine. I have a mongoDB container and a node JS container.
To connect the two I would do
...ANSWER
Answered 2019-May-22 at 21:21[Edit]
Sorry my bad, the connections string mongodb://mongodb:27017
would actually work. I tried dns querying that name, and it was able to resolve to the correct ip address even without specifying ".default.svc...".
root@web-controller-mlplb:/app# host mongodb
mongodb.default.svc.cluster.local has address 10.108.119.125
@Anshul Jindal is correct that you have race condition, where the web pods are being loaded first before the database pods. You were probably doing kubectl apply -f .
Try doing a reset kubectl delete -f .
in the folder containing those yaml . Then kubectl apply
the database manifests first, then after a few seconds, kubectl apply
the web manifests. You could also probably use Init Containers to check when the mongo service is ready, before running the pods. Or, you can also do that check in your node.js application.
Example of waiting for mongodb service in Node.js
In your connection.js file, you can change the connect function such that if it fails the first time (i.e due to mongodb service/pod not being available yet), it will retry again every 3 seconds until a connection can be established. This way, you don't even have to worry about load order of applying kubernetes manifests, you can just kubectl apply -f .
QUESTION
I am running a sample code where I am parsing my env variables for mongoDB from docker run into my node js.
This is my current db config file
...ANSWER
Answered 2019-May-12 at 12:09Inside the container, localhost does not refer to your local machine. With iOS or Windows, you can fix this by replacing localhost with host.docker.internal
in your MONGODB_URL
. This will resolves to the internal IP address used by the host. If using Linux, you can instead use the flag --network="host"
in docker run
.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install express-mongo-crud
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page