Giter VIP home page Giter VIP logo

vscode-mongodb's People

Contributors

chrisdias avatar ejizba avatar microsoftopensource avatar msftgits avatar sandy081 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-mongodb's Issues

require('mongodb') fails

New to Visual Studio Code, new to Node.js and new to mongodb. I am running OS X 10.12.X

My mongodb is an instance on atlas, so the mongo server is NOT running locally.
node --version is v9.2.1

I can connect to my mongodb using the shell access tool from mongdb. I can connect to my mongodb instance using a PHP script on my computer.

I can invoke my js script via the command-line / node, and it connects to my mongodb instance.

However, when I invoke my js script from inside Code, I get this error as reported in file "fs.fs" and in the function "fs.existsSync":

Exception has occurred: Error
Error: ENOTDIR: not a directory, stat '/Users/gene/MusicDB/node_modules/require_optional/index.js/package.json'
at fs.existsSync (fs.js:346:13)
at find_package_json (/Users/gene/MusicDB/node_modules/require_optional/index.js:14:9)
at find_package_json_with_name (/Users/gene/MusicDB/node_modules/require_optional/index.js:34:20)
at require_optional (/Users/gene/MusicDB/node_modules/require_optional/index.js:69:13)
at Object. (/Users/gene/MusicDB/node_modules/mongodb-core/index.js:8:20)
at Module._compile (module.js:641:30)
at Object.Module._extensions..js (module.js:652:10)
at Module.load (module.js:560:32)
at tryModuleLoad (module.js:503:12)
at Function.Module._load (module.js:495:3)

I am able to connect to a locally-running mysql server from inside Code. I've installed several other npm packages just to see if I could use them, and none of them have had any problems. Only the mongodb package appears to have an issue. I have since removed all references to node and npm and did a fresh install with only "mysql" and "mongodb" being installed by me. Still, no luck.

unexpected token error with insertMany

this fails with "unexpected token i in JSON at position 2". Note the space between { and id:

db.stickers.insertMany([
    { id: '1',
        tags: [ 'Deployment' ],
        name: 'Docker',
        description: 'The Docker container-based platform deployment system',
        author: 'Docker',
        size: {
            width: '2in',
            height: '2in'
        },
        image: '/img/logo/docker.png'
    }, {
        id: '2',
        tags: [ 'Service' ],
        name: 'Trello',
        description: 'The Trello project management service',
        author: 'Trello',
        size: {
            width: '2in',
            height: '2in'
        },
        image: '/img/logo/trello.png'
    }
])

This works (note no space between the first { and id):

db.stickers.insertMany([
    {id: '1',
        tags: [ 'Deployment' ],
        name: 'Docker',
        description: 'The Docker container-based platform deployment system',
        author: 'Docker',
        size: {
            width: '2in',
            height: '2in'
        },
        image: '/img/logo/docker.png'
    }, {
        id: '2',
        tags: [ 'Service' ],
        name: 'Trello',
        description: 'The Trello project management service',
        author: 'Trello',
        size: {
            width: '2in',
            height: '2in'
        },
        image: '/img/logo/trello.png'
    }
])

Using db.<collection>.find to find based on _id and ObjectId

I'm on Windows version of VS Code version 1.18.1, have mongo v3.4.4.

In a Scrapbook, I have this command:
db.<collection>.find({"_id": ObjectId("5a12639c9e07f595e0c79c89")})

and I get this error:

ObjectId is not defined

Have also tried with ObjectID.

Am sure this will be a basic issue. Any ideas?

Provide intellisense in for queries and projections

While testing microsoft/vscode#25332.

The extension should provide intellisense on properties and potentially property values when creating a query.
For example:

db.user.find({name: 'kiefer'})

Intellisense support could be provided for name and for kiefer.

Similarly, there should be intellisense support when constructing a projection:

db.user.find({}, { name: 1})

Intellisense support could be provided for name.

confusion between 2 "localhost" instances of mongodb

  • local mongodb is running on localhost:27017
  • a second instance of mongodb is running in a container, on localhost:27018
  • this should be enough to start the container (although I am running with a docker-compose file)
docker run -p 27018:27017 mongo
  • connect to a database/collection on 27017
  • db.collection.find() and copy the results
  • connect to a database/collection on 27018
  • db.collection.insertMany([{...}] and paste in the clipboard contents

results

  • connection in status bar does not show port, so hard to tell what you are connected to
  • this is vague, i know, and i'm sorry, but the insertMany would simply stop working and at that point I couldn't connect to any database. Had to reload VS Code to reset everything.

What i'm trying to do is get data into a running mongo container because once the container is stopped all data is lost.

Failed to autocomplete collections with error "Pool destroyed"

Steps to Reproduce:

  1. Connect to Azure CosmosDB by clicking 'Add Server' and pasting the connection string from the portal
  2. Right click on a DB and connect
  3. Create a new scrapbook
  4. Type 'db.'

Expected: An autocompleted list of collections and functions pops up
Actual: No list pops up and this error is displayed:
[Error - 4:15:30 PM] Request textDocument/completion failed.
Message: Request textDocument/completion failed with message: pool destroyed
Code: -32603

NOTE: This problem isn't the most consistent to repro. Try opening up multiple scrapbooks and typing 'db.' in each to see if it repros.

INVALID text edit warning in console

Testing microsoft/vscode#25332

  • create a db connection
  • open the test db and paste var let = db.inventory.find({status: "A", qty: { $lt: 30 }})
  • press enter and type re

Error in console: 'INVALID text edit -> must be single line and on the same line'

The example likely doesn't make any sense...

tree not being refreshed on windows

running on windows 10...

add a new connection
result: the Mongo tree is not updated to see the connection
press refresh button
result: same, no connection in the tree
reload/restart VS Code
result: now i can see the connection and work with it
drop a database
result: database is still in the tree
reload/restart VS Code
result: now the database is removed from the tree

i dont see this on Mac, only windows

Error: write EPIPE

I have a database in my local mongo called admin and it has a collection called system.version. I don't know where it came from unfortunately. I don't see the system.version collection in compass:

image

In VS Code, it looks like this (with errors):

image

When I click on the system.version node, I get prompted to enter the path to mongo shell in the Command Palette I put in the following:

c:\program files\mongodb\server\3.4\bin

which creates the following setting:

"mongo.shell.path": "C:\\Program Files\\MongoDB\\Server\\3.4\\bin"

When I click on the system.version node in the explorer, I get two errors:

Timed out executing use admin
Error: write EPIPE

So there are two issues here:

  • I don't know if I'm supposed to put in the folder where mongo.exe is, or the full path to mongo.exe. I did just the path and ran into problem 2
  • Provide a friendly error message if the path is wrong

Allow access to multi-tenant mongo server

While testing microsoft/vscode#25332

When you run your database on mlab you get a multi-tenant setup. I.e. a single mongo server has multiple databases but you are only allowed to access the db you own.

The mongoshell handles that case without issues:
mongo mongodb://<dbuser>:<dbpassword>@<server>.mlab.com:55574/<database> works without issues.

When I try to use such a connection string the in extension I get an error since the extension tries to list the databases:

not authorized on admin to execute command { listDatabases: 1 }: MongoError: not authorized on admin to execute command { listDatabases: 1 }

Persisting to database results in unexpected behaviour

Say I click on a collection and am shown the results in a json format, when I remove an entry in the json representation now and click update, it should be removing that entry right?
The nRemoved count should be 1, instead I get this:

{
"ok": 1,
"writeErrors": [],
"writeConcernErrors": [],
"insertedIds": [],
"nInserted": 0,
"nUpserted": 0,
"nMatched": 10,
"nModified": 10,
"nRemoved": 0,
"upserted": []
}

Am I completely misunderstanding this tool somehow?

"double colon in host identifier" - replica set connection

After connecting to Replica Set (Atlas) URL I can see the MongoDB connection as the name of the first cluster, I can see the databases in there, but when trying to see the contents of the database all I get is an error saying: "double colon in host identifier".

Any workarounds?

no intellisense in .mongo scrapbook

platform: windows
running from source in latest insiders build (may 22)

steps to reproduce:

connect to mongodb://localhost:27107
click on a database, and then a connection

result: status bar indicates that we are connected to the database...

add a new scrapbook file using the new scrapbook button
in scrapbook, type in db.

result: no intellisense

open command palette, type in >Mongo: Connect Database and choose the database
in .mongo scrapbook, now I get IntelliSense, etc.

The problem is that the status bar and the ability to click on a collection and see the top "X" records makes you think you are connected to the database. I kind of like the idea of clicking on the database/collection to set the active connection. but, i would want to try it first.

Create new scrapbook fails

Steps to repro:

  1. Create a scrapbook
  2. Save it
  3. Close VS Code
  4. Re-open VS Code to the same workspace
  5. Create a scrapbook

Expected: It creates a scrapbook with '2' in the name since a file already exists with '1' in the name
Actual: Nothing happens: no file is opened and no error is shown

Typo in /src/mongo/services/mongoScript.ts

Was reading through the repo and found this in mongoScript.ts:

private jonLanguageService: JsonLanguageService

in the MongoScriptDocumentManager class. I assume jonLanguageService should be jsonLanguageService. Unless "jon" is the internal Microsoft name for "json" :D

As it's a private member I don't think its breaking anything else, but I figured I'd report it anyway.

When I try to open a database after I logged with a password that contains @ I get the following error: "Username containing an unescaped at-sign"

Steps to reproduce:

  1. Add a server with a connection string that has @ inside the password: e.g.
    mongodb://admin:p%[email protected]:27017/test?authSource=admin
    I escaped the @ with %40 because the connection string is an URL.
  2. The server is added with success, the connection is made and the databases are read and displayed in the tree.
  3. If I click on a database in the tree, I get the following error message:
    [Error - 03:43:45] (node:840) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 18): Error: Username containing an unescaped at-sign

Here I can see two problems:

  • The error message is missleading (not the username contains an @ )
  • If the connection was successful using an escaped character, I expect that retrieving collections from a database that was read without error should succeed.

My computer has the following applications installed:

  • MongoDB & MongoShell 3.2.3 x64
  • Visual Studio Code 1.18.1 x64
  • MongoDB Extension 0.0.1

For more information please check the attachment.

error

command 'mongo.addServer' not found

With the latest VS Code x64 v1.16.1, hitting the 'Add Server' button on the extensions gives the Error "command 'mongo.addServer' not found.

This was previously working but I recently updated to v1.16.1 and the extension started providing this error shortly after.

the command can only run one the first line in "Scrapbook"

when i try to write command in the "Scrapbook" and to run it, and i find out that it can only work when i run selected command on the first line.And also the IntelliSense works for the only first line.
I wonder it's my owm problem or it's the way works.

automatically open localhost?

Should we automatically try to open mongodb://localhost when the extension starts? many (most?) will probably have mongo installed locally so its one less thing they have to do.

cannot do find() projection

Try running this from a mongo document (any collection, does not matter if its stickers):

db.stickers.find({}, {"_id":0})

The result will still contain the _id field.

Run the same query from the Mongo shell and the _id field is not in the result set.

It is not just the _id field, you can't do any projection such as:

db.stickers.find({}, {"name":1, "_id":0})

Mongo extension is not activated if VS Code is opened without a workspace

Repro steps:

  1. Open VS Code without a default workspace (if necessary, open VS Code, go to 'File -> Close Folder', close Code, and re-open)
  2. Click the mongo 'New Scrapbook' button

Expected: A new scrapbook opens
Actual: 'Error command mongo.newScrapbook not found'

This error occurs because we depend on ExtensionContext.storagePath, which is undefined if no workspace is open. We should use globalState instead so that settings are persisted across workspaces and since it should always be defined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.