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 ex...

How Kafka replaced Zookeeper with the (K)Raft algorithm?

Back in 2021, when I first came across Kafka, I remember the DevOps engineer in my team using terms like Zookeeper, broker configs, etc on our team standup calls. I remember not caring about those terms, and simply focusing on learning about the producer, partitions, topics and consumer groups, and how they could be used in the product my team was developing. While platforms like Kafka were built to abstract certain aspects of distributed computing (replication, consistency) while storing & processing logs, it's a pity how so many of us miss out on knowing the amazing engineering that went behind to build the different parts of a platform such as this one. 4 years later, I'm hungry enough to reverse engineer one of my favourite distributed platforms - Kafka! What did the Zookeeper do? To quote the 1st  Kafka paper from 2011, Kafka uses Zookeeper for the following tasks:  (1) detecting the addition and the removal of brokers and consumers,  (2) triggering a rebalance ...

"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...