DEV Community

loading...

Want to convert any SQL Query to Mongo DB Query - Shortcut

Kushal
Full Stack Developer works on #100DaysOfBlockchain, React, JavaScript, #100DaysOfCloud, #LogicCodeDebug, .Net & exploring #abc_vi (AI | VR | IOT | Quantum)
・1 min read

Starting with Mongo DB and confused, how to proceed. MongoDB documents are a good way to proceed.

But there is an alternative that you can follow. Open any mongoDB GUI tool. Like in my case, I am using free version of No SQL Booster.

Suppose you want to convert below query to mongo query:

select movies.title 
from movies 
inner join ratings on movies.movieId=ratings.movieId 
where movies.genres like '%Children%' 
and ratings.rating>3 
group by movies.title;
Enter fullscreen mode Exit fullscreen mode

Steps:

STEP 1: Connect your Mongo DB Query String, and select this SQL as shown in image:

image

STEP 2: You wll see a text area with mb.runSQLQuery() as shown below. You can write any query, and click on Code. The code will be generated below as shown in image. Don't worry, it converts all the queries, doesnot connect on the database.

image

Discussion (0)