API Builder Docker Image for connecting to a MongoDB DB
335
API Builder Docker Image for connecting to any MongoDB DB (with existing collections) using a connection url as an environment variable
Based on API Builder 4.0 Standalone – From Zero to Dockerized Microservice
docker run --rm --name apibmongodb -p 80:8080 -e MONGO_URL={MongoDB Connection URL} apibmongodb OR docker run --rm --name apibmongodb -p 80:8080 -e MONGO_URL={MongoDB Connection URL} lbrenman/apibmongodb:1.0.1
e.g. docker run --rm --name apibmongodb -p 80:8080 -e MONGO_URL="mongodb://{MongoDB Username}:{MongoDB Password}@{Host}:27017/{DB Name}?authSource=admin" apibmongodb
Once running, can be tested (locally) using:
curl 'http://localhost:80/api/mongo/{CollectionName}'
e.g. curl 'http://localhost:80/api/mongo/dog'
Note that there is no security on the APIs. It is recommended to front end the API with an API Gateway
Complete list of API's are:
Delete all: DELETE /api/mongo/{collection}
Create: POST /api/mongo/{collection}
Find all: GET /api/mongo/{collection}
Count: GET /api/mongo/{collection}/count
Query: GET /api/mongo/{collection}/query
Upsert: POST /api/mongo/{collection}/upsert
Find and Modify: PUT /api/mongo/{collection}/findAndModify
Find by Id: GET /api/mongo/{collection}/:id
Delete one: DELETE /api/mongo/{collection}/:id
Update: PUT /api/mongo/{collection}/:id
Distinct: GET /api/mongo/{collection}/distinct/:field
Versions:
Content type
Image
Digest
Size
45 MB
Last updated
over 7 years ago
docker pull lbrenman/apibmongodb:1.0.1