Tech IndustryMar 19, 2023
CiscoNewbPython

Sql-like CLI for mongodb?

I just hate typing db.foo.find({name: bear}) in mongo's CLI because pressing the shift key multiple times for brackets really slow me down. I like how I could just do select * from foo where name=bear. Able to type this kind of query fast and easy. Is there a tool where I can type sql queries and retrieves data from mongo? Don't like using their UI (mongo compass) because using the mouse slows me down even more TC 180 HCOL

Iterable plznoban Mar 19, 2023

Shoulda used a relational database bro.

Amazon shunted Mar 19, 2023

Why don't you write a tool for it? Seems like a good project.

Cisco NewbPython OP Mar 19, 2023

Good idea. I think I'll do that

New
mint_tea Mar 19, 2023

You can use an abstraction layer over it like Spring Data Mongo if you are using Java or write your own SQL to mongo translator using Apache Calcite. Edit - someone already did that, there is a calcite-mongo library.

Cisco NewbPython OP Mar 19, 2023

Thx, gonna check it out!

Classy.org svxa11 Mar 19, 2023

Even if you could save one second from typing that instead of moving the mouse and typing {name:bear}, it’s literally insignificant time savings

Cisco NewbPython OP Mar 19, 2023

Might not seem a lot to you but it's a lot to me. 1s per query we talking about here

NVIDIA touché 🤺 Mar 19, 2023

I know a few tools. They're people though not CLIs.

Amazon Shai Hulud Mar 19, 2023

Use ddb

Goldman Sachs 💊popper Mar 19, 2023

Simple, just use Postgres

New
mint_tea Mar 19, 2023

This is true on a non - sarcastic level too. Most SQL databases these days have document storage built in, like postgres jsonb columns. Problem is usually one moves to nosql for the horizontal scaling aspects, so I'd say move to NewSql instead like Yugabyte or Cockroach db or TiDb, which scale horizontally yet offer atomic rdms style persistence. some of these are postgres wire compatible so you often do not even need to change your application's postgres drivers.

MongoDB datadebase Mar 19, 2023

Jeez. No time for the shift key. Busy days.

MongoDB mmm86 Mar 19, 2023

Just make some aliases in your terminal. Super basic, super easy, and you can make them whatever you want. If you aren't familiar with making your own aliases for your development workflow, highly recommend reading up on it cuz I use it for nearly everything I do in the terminal, not just when working with mongdb

Cisco NewbPython OP Mar 19, 2023

You talking about the alias you put in your bashrc or zshrc, like kubectl becomes kl, or mongodb becomes mdb? When the sql queries become a little more complex than select *, might become overwhelming

MongoDB mmm86 Mar 19, 2023

Yeah that's what I'm referring to. Definitely doesn't solve everything OP needs but should help a bit to reduce some of the repetitive stuff. I have a couple I use for basic finds or a simple aggregation when I am interacting with the same db over and over