DEV Community

Kushal
Kushal

Posted on

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

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

Top comments (0)