This is the code example for the Running Bun With MongoDB tutorial.
To run this project, you need to install bun, as explained on their website.
If you don't want to install bun, you can use the docker image
oven/bunto run the project. Replacebunwith the following command.
docker run --rm --init --ulimit memlock=-1:-1 -v .:/opt/app -p 3000:3000 -w /opt/app -e PORT=3000 oven/bun <params>ie.
bun installbecomesdocker run --rm --init --ulimit memlock=-1:-1 -v .:/opt/app -p 3000:3000 -w /opt/app -e PORT=3000 oven/bun install:::
If you want to start with a MongoDB and Bun template, you can run the following commands.
git clone https://github.com/mongodb-developer/bun-with-mongodb
cd bun-with-mongodb
bun i
echo "MONGODB_URI=<your_atlas_connection_string>" > .env
bun run index.ts