mongo.nvim
mongo.nvim copied to clipboard
password and username
Thank you for doing this plugin.
Is there a way to connect to a password protected instance? I have tried two ways:
1
This...
:Mongoconnect --host=<my-db-ip> --db=<my-db-name> --username=<my-username> --password=<my-password>
:Mongocollections
... gives this error...
Error executing Lua callback: Vim:E474: Unidentified byte: MongoServerError: there are no users authenticated
stack traceback:
[C]: in function 'json_decode'
...arald/.local/share/nvim/plugged/mongo.nvim/lua/mongo.lua:68: in function 'get_collections'
...cal/share/nvim/plugged/mongo.nvim/plugin/mongo/mongo.lua:64: in function <...cal/share/nvim/plugged/mongo.nvim/plugin/mongo/mongo.lua:63>
2
This...
:Mongoconnect mongodb://${username}:${password}@${host}:${port}/${name}
...gives this error...
Error executing Lua callback: Vim:E474: Unidentified byte: MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017
stack traceback:
[C]: in function 'json_decode'
...arald/.local/share/nvim/plugged/mongo.nvim/lua/mongo.lua:43: in function 'get_dbs'
...cal/share/nvim/plugged/mongo.nvim/plugin/mongo/mongo.lua:50: in function <...cal/share/nvim/plugged/mongo.nvim/plugin/mongo/mongo.lua:47>
@FilipHarald at the moment, this plugin does not take into account auth-protected DBs, so the errors you are getting are expected. To me, this seems pretty fundamental, so support for this should be added soon. I'll be thinking about what the best way to add this would be and post back here.
I'm considering changing how :Mongoconnect works: right now it is confusing and the options/combinations are not really documented well or very predictable. Just this morning, I was hung up using it for a little bit (and I wrote it!). I'm considering just changing it to pass its argument unaltered to mongosh.
The drawback is that this change would be backwards-incompatable. Thoughts? @FilipHarald
OK, I'm not sure I know the implications of that security-wise. It sounds sane to have the interface as similar as possible to mongosh though.
What goes for backwards-incompatibility that is not an issue for me. @jrop
Alternatively, it would be amazing if we could pass a connection string like:
:Mongoconnect --uri mongodb+srv://username:password@host:port/db_name