I turn coffee into bugs ☕🐛
Understanding Index in MongoDB Part 1 🥰
Index is a very popular technique to increase search and sorting performance in databases. This article will explore basic Index concepts, especially in MongoDB. What is Index Index is a very popular technique in databases to increase query performance. Especially when the database has a lot of data, say 10000 records, we can’t linearly scan from 1 to 10000 to find. Index in real life is like when we go to a bookstore to find books, we can’t search sequentially through each book - the bookstore has marked each area by different book types so we can search easily. ...
How to Add Properties to Object in TypeScript 🎉
Have you ever wondered how to add Properties to a predefined Object without getting error “Property ‘x’ does not exist on type ‘y’”? This article will answer that for you. 😁 The Problem interface Student { name: string; age?: number; } const sang: Student = { name: "Sang", }; sang.age = 20; // 👈 Error: Property 'age' does not exist on type 'Student' Some might think just add age directly to Student. That would have a big problem: If only the sang variable has age, it won’t work. Because when adding age to Student, all other Student type variables must also have age. ...
Fetching Issues in Client Component with use 🎉
Let’s explore what use is as well as issues that not everyone knows when using it, how to fix them and code examples 😁 What is USE It is first-class support for Promise in ReactJS. Instead of using await for a promise in async function, we wrap that promise with use: “use is a new React function that accepts a promise conceptually similar to await. use handles the promise returned by a function in a way that is compatible with components, hooks, and Suspense.” ...
Caching with Redis in NodeJS Server 🥰
If you already understand what Redis is, let’s learn more about how servers use caching through Redis, specifically with NodeJS 😉 What is Cache Cache is a buffer memory, stored in memory, so it has very fast access speed. Instead of requesting data from Server and then Server queries to Database, with cache it will return available data immediately, no need to query to Database. How it Works Suppose you own a very busy bubble tea shop, if every customer comes to order and then you make bubble tea, it will take a very long time to serve everyone waiting behind, they may leave because they wait too long. So we have to use a method of making batches of bubble tea and putting them in the fridge, ready for whoever comes. ...
Rush B Redis Basics 💥
Today’s blog will explore the concept of Redis, packaging basic Redis concepts for those who want to quickly understand what it is and how to use it. What is Redis? Redis a.k.a REmote DIctionary Server is an open-source NoSQL database that stores data in Key-Value format, can be used as a database, commonly used as Cache memory working together with other databases. Its strength is storing data in RAM so access speed is super fast. Compared to MySQL, MongoDB, etc., data is stored on hard disk. ...
Streaming in NextJS with ReactJS 🎉
NextJS 13 with ReactJS 18 has enabled a new data fetching mechanism called Streaming. This article will dive into the core of NextJS to understand what it is, how it works, and how to implement it 😊 1. What is Streaming Streaming is a method that allows you to display UI Components progressively instead of waiting for everything to load before showing. Example: 2. The Problem Without Streaming With SSR (Server Side Rendering) in NextJS, we first need to understand how it renders and displays to users. The steps are sequential: ...