I'm looking to build a Sveltekit app with Mongodb on the backend. I want to run mongodb as a docker image. I don't want to use Atlas or any any other db as a service type things. The issue is that almost all the tutorials I found online only show you how to use Mongodb integrated into an app with Atlas using a db connection string. I can't find that many tutorials on how to use Mongodb locally (or even just not associated with Atlas). I have this docker-compose file to build the Mongodb instance:
version: '3.7'
services:
mongodb:
image: mongo:latest
container_name: mongodb
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: mongoadmin
MONGO_INITDB_ROOT_PASSWORD: <PASSWORD HERE>
MONGO_INITDB_DATABASE: mongo1_0
ports:
- 27017:27017
volumes:
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
And when I connect to it via Insomnia (which is similar to Postman) using an empty GET request to localhost:27017/, I get this: It looks like you are trying to access MongoDB over HTTP on the native driver port.
The good news is that I can connect to it. So how do I create a schema via an API call? Or Add, Delete, Update entries in this db via API requests? If I can figure out how to add, query, and edit entries, I can incorporate those requests into my Sveltekit app.