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.


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

"Hey Google" get me a new T-shirt

Everyone loves Google for its amazing technology and creative workspaces! Guess what? Google loves its developers as much as the world loves it too! And yeah, you don't need to be an amazing programmer to be a developer in Google's community. All you need to do is to spare 30 minutes, just once, and maybe have some creativity! That's it! Oh, and you should be really checking your mails periodically, although if you don't currently have this habit, your excitement would develop that for you. What do we want? So you arrived here to know about getting a T-shirt. Would you also like having a Google Home ? Yup, that is also something you could get through this. And of course, as I mentioned earlier, an entry to Google's Developers Community Program! There're a lot of perks for it but let's first talk business. What do we have to do? In a nutshell: Make an Action for Google Assistant .  But what's an Action ? Action is a feature, or a sub-applicat