Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for raw/shell queries #37

Closed
richard-mihalovic opened this issue Jun 14, 2023 · 7 comments · Fixed by #44
Closed

Support for raw/shell queries #37

richard-mihalovic opened this issue Jun 14, 2023 · 7 comments · Fixed by #44
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@richard-mihalovic
Copy link

richard-mihalovic commented Jun 14, 2023

Feature description

Hi. The query builders are nice, but sometimes I like to write queries directly in one text box.

Something like this ...

db.getCollection('COLLECTION').updateOne(
    {
        _id: ObjectId('...')
    },
    {
        $set: {
            last_updated_at: new Date(),
            ...
        }
    }
);

Importance

Nice to have

@garraflavatra
Copy link
Owner

Thanks for the feature request and for using Rolens!

I completely agree, and think it would be very useful to include some sort of Mongo Shell functionality so that you could type queries as a shell command. Or maybe it's possible to extract such a command to the query builder.

I would love to start working on this now, though I haven't got much time the next couple of weeks. This feature will be shipped with v0.3.0, which will come after v0.2.1 (the upcoming release).

When I have time to build this, I'll let you know. The estimate is 2-3 weeks.

@garraflavatra garraflavatra added this to the v0.3.0 milestone Jun 14, 2023
@garraflavatra garraflavatra linked a pull request Jun 24, 2023 that will close this issue
@garraflavatra
Copy link
Owner

@richard-mihalovic: I've implemented a first, basic version; what do you think? (please see screenshot below, or PR #44)

Scherm­afbeelding 2023-06-24 om 11 24 13

It currently uses a local installation of mongosh (if any).

@garraflavatra garraflavatra removed a link to a pull request Jul 1, 2023
garraflavatra added a commit that referenced this issue Jul 1, 2023
Resolves #37: adds a shell tab where the user can write mongo shell
scripts and execute them.
@garraflavatra garraflavatra reopened this Jul 1, 2023
@garraflavatra
Copy link
Owner

Hi. I've just merged #44. Before releasing 3.0, I'll add a 'save query' button which lets you save and re-use queries (just like in the find panel).

I'd love to hear what you think about it. Thank you for your feature request!

Scherm­afbeelding 2023-07-01 om 21 37 57

@richard-mihalovic
Copy link
Author

Hi, the shell looks promising (nice progress). Some quick thoughts.

  1. I needed to install mongosh over 'brew install mongosh', it will be nice to show this info somewhere in documentation.
  2. Is it possible to embed the mongosh dependency to "release binary" that user do not need to install it ?
  3. When I switch 'Shell tab' to 'Find tab' the content of "Shell tab" is cleared.
  4. When I enter bad "shell query" it doesnt show any error message.

I will test more during the week.

@garraflavatra
Copy link
Owner

  1. Good point. Honestly I haven't spent much time to writing docs.
  2. It should be possible to embed it. The mongosh executable appears to weigh only 4 KB.
  3. Ouch. It should instead remember its state so you don't lose your script.
  4. It seems that I forgot to print the standard error output of the mongosh command, which writes its errors to standard error. Now, standard output is the only thing that's shown…

I'll try to fix these points.

@garraflavatra
Copy link
Owner

Sorry for the delay. The following items (1, 3, & 4) are fixed now:

  • Remember script after navigating to another tab
  • Added documentation on mongosh installation
  • mongosh errors are printed (in red)

Furthermore, there is now an option to switch between horizontal and vertical panels. That may be useful when your script or output contains long lines.

The mongosh client turned out to be written in Node.js (TypeScript), which means that Node.js must be installed, and that it comes with a bazillion of Node dependencies. In my humble opinion this is a bit too much to embed :)

I added a big blue button to the shell script editor that points to the installation docs, plus some explanatory notes. Would that be sufficient?

@garraflavatra
Copy link
Owner

Hi Richard, hope you're doing well. I've just released v0.3 containing the shell functionality (as well as some other improvements).

I'm closing this, but feel free to reach out should you have questions / comments!

Happy holidays!
Romein

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants