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

An introduction to APIs

API is an acronym for Application Programming Interface. Let's start with first defining some basic terms: Browser: These are browsers. To visit any website on the internet, you need a browser. Server: Hmm, this is tough. In simple words, server is a computer. Yes, just like the laptop, or PC at your home. The only difference is that it does not have a screen. Of course, there are other differences in technical specifications, but at its core, the server is just, simply, a computer. That's it. So why is it called a server? Because it serves . When you go to a website like google.com , your computer connects to the internet and gets you your search result. But your computer's internet connection has to get that result from somewhere, right? If the google search result is giving you some answers, the answers have to come from somewhere. What is that place? The answer to that some place is: a server. When you click on the search button on google, or hit enter after typing, &q

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