From 0be285a38a86a0d1c72c878d2129a31ba925d944 Mon Sep 17 00:00:00 2001 From: Aboo Date: Mon, 23 Dec 2024 21:49:00 +1100 Subject: [PATCH] #4 Add database selection documentation - Add "Database Selection" section to README.md - Clarify default "test" database behavior - Include connection string examples for different databases --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index fb0f42b..84fe9b7 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,24 @@ To get started, find your mongodb connection url and add this configuration to y } ``` +### Database Selection + +The database name can be specified in the MongoDB connection URL path: + +``` +# Format +mongodb://username:password@host:port/database_name?authSource=admin + +# Examples +mongodb://root:example@localhost:27017/myapp?authSource=admin # Uses "myapp" database +mongodb://root:example@localhost:27017 # Uses default "test" database +``` + +Note: + +- If no database name is provided in the URL path, the "test" database will be used by default. +- MongoDB will automatically create the database if it doesn't exist. + ### Prerequisites - Node.js 18+