mongodb-js / vscode

Connect to MongoDB and Atlas and directly from your VS Code environment, navigate your databases and collections, inspect your schema and use playgrounds to prototype queries and aggregations.
https://marketplace.visualstudio.com/items?itemName=mongodb.mongodb-vscode
Apache License 2.0
319 stars 54 forks source link

Feature Request: Allow saving connection to settings.json #368

Open damienpontifex opened 2 years ago

damienpontifex commented 2 years ago

Feature Request

Ability to save connections into settings.json within the opened folder context (i.e. .vscode/settings.json) or within the devcontainer context (i.e. .devcontainer/devcontainer.json under the key "settings")

Context

Especially useful when combining VS Code remote containers and docker compose to startup the mongodb container within the workspace and have it automatically configured to be connected to the container within this setup.

As an example of how the MSSQL extension does it and then this can be added to .devcontainer/devcontainer.json

  "mssql.connections": [
    {
      "server": "{{put-server-name-here}}",
      "database": "{{put-database-name-here}}",
      "user": "{{put-username-here}}",
      "password": "{{put-password-here}}"
    }
  ]

See dotnet-mssql remote container template https://github.com/microsoft/vscode-dev-containers/tree/main/containers/dotnet-mssql for how they utilise remote containers and the mssql container for a great dev environment setup. Looking at a similar scenario with any language + mongodb as the data store

Possible Implementation

settings.json

"mdb.connections": [
  {
    "name": "connection name",
    "connectionString": "mongodb://user:password@server/database"
  }
]
langaads commented 1 year ago

+1 on this, my team have the same usecase and we are trying to automate as much as possible.

adriano-di-giovanni commented 1 year ago

+1 Also, credentials should be hidden by encrypting them or by referencing environment variables. I don't know if it is already possible in settings.json because the documentation mentions launch.json and tasks.json only. Given these possibilities, I could provision the remote environments and provide the developers with the connections they need on a per-repository basis.

seesharprun commented 1 year ago

+1, I'm using the MongoDB extension in a devcontainer with a backing docker-compose file. It would be amazing to pre-populate the interface with a connection.

coderhammer commented 4 months ago

Same problematic here. And I can't find how to access secrets on my docker container to eventually replicate the information across machines... Any help is highly appreciated if you managed a way!

Thanks for the amazing extension by the way