Love the VS Code extension but

The VS Code extension is my tool of choice for developing aggregation pipelines. I am experiencing two problems. Can someone advise on how to fix these?

  1. Whenever I drag to select a bit of code, the editor ‘inserts’ a line asking me if I want to execute the selected code. It causes all the code below to shift down a line and makes selecting code very irritating.

  2. The editor does not sense and redline JSON syntax errors. To work around this, I switch the file association to “JavaScript” whenever I am seriously editing a pipeline. Then I switch the file association back to “MongoDB” just before testing/executing the pipeline. This is inconvenient.

Anybody know workarounds for these? Is there some Preference or Setting I’ve missed?

Hi @Peter_Winer, thank you for your feedback and for sharing your frustrations. It’s really valuable for us to know how you use playgrounds in VS Code and where we can improve the experience.

For 1, we currently don’t have a setting to disable partial execution support. Let us take a look and see if it’s something we can easily add. Out of curiosity, is partial execution a functionality you see yourself using in some situations?

About 2, we need to check the language grammar we are using for playground. It’s possible that for some reason it only checks for valid JS but not for valid JSON. Could you share a screenshot of where you’d expect to see syntax errors?

Lastly, would you mind adding these as suggestions in our feedback portal?

1 Like

Hi, thanks for the rapid reply.

I don’t really see myself using the partial execution feature. I understand it can be useful, and I sometimes use similar features in other tools. For example, there is a RegEx extension where this is quite valuable.

Here is a little snip that should display an error:


If I switch to JavaScript file association, the error is shown as a redline:


… and it’s also logged in the Problems display:


I would like to have this capability without having to change the file association for .mongodb files.

Thanks - Peter.

1 Like


I totally agree about better JSON parsing as a baseline, especially while the intellisense support gets ramped up.

@Peter_Winer thank you for clarifying. I captured your suggestion for the syntax checking here:

Regarding the code lenses for partial execution, we are currently evaluating what’s the best way to allow customizing this behavior so users who don’t need this feature don’t have that jumpy behavior.

@Massimiliano_Marcon - Thank you so much. Looking forward to the solution.

FYI, I’ve tried various tools for building aggregation pipelines. The VS Code extension is the best. One additional feature would make it truly awesome:

Provide a way to run an aggregation pipeline one step at a time, just like MongoDB Compass and Studio 3T. IMO, that’s the only missing feature.

Occasionally, I will run an aggregation in MongoDB Compass, just to see such intermediate results. Otherwise, I always use the VS Code extension.

Thanks - Peter.


To make that feature really useful, it would make sense for the parser to clearly recognize the stages in the pipeline.

Since in reality, I would like to be able run say stage 1 and 2, while working on stage 3, without having to comment out stage 3, to re look at output from stage 1 + 2.

However because of the way I format my, I end having to format my pipleline code like so: -

, {$facet


So I can easily comment out the $facet stage for instance. Maybe the aggregation pipleline, needs a optional parameter, where you enter the stages you want to run {1,2,5} :slight_smile:

Another, related question. This one is very specific.

When I launch mongo from within the VS Code extension, it uses a connection string that sets “w=majority”. As a result, I can’t run explain() on my aggregation pipelines. Mongo won’t allow this for pipelines with write concerns.

Where is this connection string stored, so I can access it and edit it?

Thanks - Peter.

I am almost certain that the connection string the extension passes to mongo is the same connection string you used when you added the connection to the extension. You don’t have a way to edit the connection string of an existing connection, but you can copy it and recreate the connection without w=majority.