Skip to main content

Programming - Finding the Easiest Way

A few days ago, I took control of a project that was written in Node & mySQL. Since the project would involve a lot of high end queries and more complex Database structure, I thought it would be best to take this battle to my comfort zone - MongoDB.
I decided to migrate from mySQL to MongoDB. I had never done this before, and I wasn't even sure if it could actually happen on a large scale.

Solution 1

The first possible solution was to do this manually using the server as a mediator.

1. I would build an endpoint that would execute a mySQL DB Query pulling everything from a table.
(Ex. 'SELECT * FROM table_name)
2. I would then make the server save everything into a JSON file using the node module fs. This concludes the endpoint.
3. With some configurations, I will have all the tables from the MySQL Database seperately in JSON formats.
4. Now, I can use the JSON content as POST Requests made to the newly built MongoDB Database.

I was about to go ahead with this solution, but I just thought of exploring how the rest of the world does this. Turned out, there were already tools for this thing.

Solution 2: Studio3T



Enter Studio3T, a powerful IDE for MongoDB. They had a specific feature just for this purpose! In just a few minutes, all the SQL database was transferred to my local MongoDB! 


This might not look like a big deal, but believe me when I say this, it took a lot of energy to persuade my lazy mind to read the documentation of a tool, when I already had a solution in mind. 

When you go through Studio 3T, you find that it really has a ton of new and amazing features! For example, it has a Visual Query Builder, which actually lets us build queries without having to know the MongoDB syntax! Isn't that amazing?!

Visual Query Builder

From a learner's point of view, learning the core syntax can be held at a higher precedence, but if you're just going to ignore treading a path that is a shortcut, how can you really call yourself a lazy programmer? In other serious words, how can you justify that you can build a project with a proper balance of speed and quality? 

As programmers, we're always looking to take pride in coding our way through everything. Yes, we're known for finding the easiest way out of everything, but sometimes the easiest ways are already built in the form of applications, rather than modules or libraries. If you refuse to use them, it might take a lot of time for you to build something what is already built, and it will definitely take years to build something that significantly helps the world.




Comments

Popular posts from this blog

Namaste JavaScript Quick Notes

Note:  Akshay Saini's Namaste JavaScript is probably the best course for JavaScript developers out there. These are my personal notes that I made while watching the course; they serve more of as an online quick reference for my understanding and revision, and I hope it benefits anyone reading it too! Everything in JS happens inside an Execution Context. Before a JS code is run, memory is allocated and variables are set as undefined   , and functions are set as their exact code in the scope within the Execution Context. The global execution context hosts all the global variables and function definitions. An Execution Context has 2 components: Memory, that stores variables and functions; and Code, that reads and executes the code. Call Stack maintains the order of execution contexts. Since JS is single threaded and asynchronous, at one point of time, only one function is executed which is at the top of the call stack. For each function, an execution context is created before executi

i3wm essentials - I (Brightness)

So you have started using i3 and somehow managed to open your browser and almost resumed your normal work.  But wait, the brightness is too much isn't it? Or is it too low? The mousepad used to work fine, but now all of a sudden tapping does not equal click?!  Don't worry.  This blog series will tell you all about the essential setup commands and common shortcuts that I use to navigate my work in i3, and how you can too. Changing the brightness So you just started i3 and you just can't take this brightness setting. You go for your function keys, and damn! They aren't working. Quick fix: Run the following command if you need to change the brightness ASAP. xrandr -q | grep ' connected' | head -n 1 | cut -d ' ' -f1 This will give an ouput that's the name of your monitor.  Use that monitor name here and change the values of brightness to suit your needs. xrandr --output <monitor-name> --brightness 0.7 Now that your eyes are comfortable, let me show

i3wm essentials - II

Welcome back! Let's continue this guide with other setup essentials for i3. Enabling Mousetap Chances are that if you're using a laptop, then tapping on the mousepad does not equal a click for you. You need to enable tapping in your config. Fortunately, there is one documentation available that works for majority of the setups. I don't need to explain this one in detail. Here you go: Enable tap to click in i3 . Volume Control This one is simple again. Do you remember the i3 config file I talked about in the previous blog ? All you need to do is go to that file and find the line: bindsym XF86AudioRaiseVolume Just below that line you will find lines with XF86AudioLowerVolume and XF86AudioMute too. Anyway, the truth is, there are 2 sets of lines with these keywords. Chances are that the line: bindsym XF86AudioRaiseVolume exec --no-startup-id pactl -- set-sink-volume 0 +5% Will be uncommented and the line: bindsym XF86AudioRaiseVolume exec --no-startup-id pactl -- set-sink vo