Imagine you’re a DevOps engineer and you are responsible to grant access to the database, which could be known as Database Administrator as well.
However, it’s a new year and your company management decided to restructure the team. Someone from the team trying to change his role. For example, “ devA” from the backend team would like to try to do different stuff in his career and he decides to switch to the frontend team.
The management informs you to revoke his database privileges as he previously offered access to the database. …
Imagine you’re a DevOps engineer and you are responsible to grant access to the database, which could be known as Database Administrator as well.
However, it’s a new year and your company management decided to promote some of the potential team members to become the team leaders. 🎉🎉🎉
As you all known:
With great responsibility comes great power. — Mark Manson
The management informs you to update their database privileges as they previously offered read-only access to the database. If you’re interested in how to create a read-only role for MongoDB, please read the post here. …
This post discussed how to create a read-only role in the MongoDB database. Without further ado, let’s start.
Imagine you’re a DevOps engineer or the team leader for the Backend team, normally these roles are the role to grant access to the database.
There are two newly hired developers who just joined your team and the management decided to provide a read-access only to the database in the staging environment in order to ease the debugging workflow. Let's call them Developer A and Developer B.
Here is the list of Mongo databases that is available.
This post talked about one of my experiences in code review and ultimately lead me to the discovery of the difference between Array.isArray
and Lodash _.isArray
. Without further ado, let’s start the story.
The story starts by beginning sending a merge request for review in Gitlab. It is similar to the pull request you known in Github.
In the code itself, I am using lodash isArray
to check the variable. Refer the below code snippet.
const { isArray } = require('lodash');const requiredFields = getRequiredFields();if (isArray(requiredFields)) {
return requiredFields;
} else {
// do something else
}
At this moment, the reasons that I use lodash here is…
This post discussed how I use jest-in-case library to write more organized tests. However, there is a pre-requisite to use this library you probably guess it right.
If you’re using Jest to write your test, then this post is probably going to be helpful to you.
“I don’t know about you, but lots of times when I write even slightly generic functions, I have lots of test cases that are basically the same test over and over with different values.” — Jamie Kyle
The above statement resonates with me a lot especially when I started to face the situation where the unit tests code I wrote is triple or quadruple to my original code change. …
This post discussed why I choose to use git alias
and how it improves the overall work productivity and save some time for me.
If you’re the one who prefers to use IDE such as Github Desktop, Fork, and others, then this article might not suitable for you. However, you can continue to read to see whether I can persuade you to use the git command instead.
Git alias allows you to create shortcuts for your frequently used Git commands. Here are some of my favorites and commands I used the most.
git checkout => git co // My shortcutgit branch => git br // My…
Writing Unit Tests has become a daily task for a software engineer. There are several purposes of writing unit test:
Since unit tests lead to so many benefits, but why there are possibilities for things go wrong. …
This post discussed how you can perform upsert with Mongoose. Upsert is the combination of insert and update, if it is a new record, it will perform the CREATE operation while if the existing record found, it will UPDATE on the existing record.
Without further ado, let’s start.
Learning is enhanced with a real case study. Imagine that you are the Backend Developer for a job portal. Here is the given requirement:
We can easily use the API provided by Mongoose findOneAndUpdate
to perform the upsert by simply setting the option { upsert: true }
. …
This article documented down on how to skip to the next iteration when you’re using foreach
. Besides, you will also know the correct scenario to use foreach
.
Without further ado, let’s start.
Skipping a foreach
loop is easy. Simply using return
when it is matching the condition. Refer to the code below.
const arr = ['Peter', 'Sam', 'Helena'];arr.forEach((name) => {
if (name === 'Helena') {
return;
} console.log(`Person name: ${name}`);
});
Output
"Person name: Peter"
"Person name: Sam"
With this example, we’re skipping the loop when the iteration reached “Helena”.
However, are we using forEach
in all the scenarios? …
This article documents how to improve MongoDB query performance using index selectivity. At the end of this article, you will know the importance of index selectivity and how you can leverage it in improving query performance.
Let’s explore the scenario we’re facing currently. We have a flight database with a booking
collection. Refer to the screenshot below for the schema.