You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, MongoDB Lens looks for the config file at: `~/.mongodb-lens.json`
457
+
By default, MongoDB Lens looks for the config file at:
458
+
459
+
-`~/.mongodb-lens.jsonc` first, then falls back to
460
+
-`~/.mongodb-lens.json` if the former doesn't exist
453
461
454
462
To customize the config file path, set the environment variable `CONFIG_PATH` to the desired file path.
455
463
@@ -465,6 +473,66 @@ Example Docker Hub usage:
465
473
docker run --rm -i --network=host --pull=always -v /path/to/config.json:/root/.mongodb-lens.json furey/mongodb-lens
466
474
```
467
475
476
+
### Configuration: Config File Generation
477
+
478
+
You can generate a configuration file automatically using the `config:create` script:
479
+
480
+
```console
481
+
# Create config file
482
+
npm run config:create
483
+
484
+
# Create config file (force overwrite existing)
485
+
npm run config:create -- --force
486
+
```
487
+
488
+
This script extracts the [example configuration file](#configuration-config-file) above and saves it to: `~/.mongodb-lens.jsonc`
489
+
490
+
#### Config File Generation: Custom Path
491
+
492
+
You can specify a custom configuration file output location using the `CONFIG_PATH` environment variable:
493
+
494
+
```console
495
+
# Save to a specific file path
496
+
CONFIG_PATH=/path/to/config.jsonc npm run config:create
497
+
498
+
# Save to a specific directory (will append .mongodb-lens.jsonc to the path)
499
+
CONFIG_PATH=/path/to/directory npm run config:create
500
+
501
+
# Save as JSON without comments
502
+
CONFIG_PATH=/path/to/config.json npm run config:create
503
+
```
504
+
505
+
The script handles paths intelligently:
506
+
507
+
- If `CONFIG_PATH` has no file extension, it's treated as a directory and `.mongodb-lens.jsonc` is appended
508
+
- If `CONFIG_PATH` ends with `.json` (not `.jsonc`), comments are automatically stripped from the output
509
+
510
+
### Configuration: Multiple MongoDB Connections
511
+
512
+
MongoDB Lens supports multiple MongoDB URIs with aliases in your [config file](#configuration-config-file), allowing you to easily switch between different MongoDB instances using simple names.
513
+
514
+
To configure multiple connections, set the `mongoUri` config setting to an object with alias-URI pairs:
MongoDB Lens supports defining multiple MongoDB URIs with aliases in your [config file](#configuration-config-file), allowing you to easily switch between different MongoDB instances using simple names.
580
+
For consistent environment variable usage across Windows, macOS, and Linux, consider using `cross-env`:
513
581
514
-
To configure multiple connections, set the `mongoUri` setting to an object with alias-URI pairs:
0 commit comments