Today’s Learning Update: Backend Basics

Storing Images in a Database

We don’t store the actual image in the database; instead, we store its link while the image is hosted elsewhere.

Understanding Collections, Schemas & Databases

Collection → Similar to a table in SQL.

Schema → Define…


This content originally appeared on DEV Community and was authored by yashi srivastava

Storing Images in a Database

We don’t store the actual image in the database; instead, we store its link while the image is hosted elsewhere.

Understanding Collections, Schemas & Databases

Collection → Similar to a table in SQL.

Schema → Defines the fields stored in a collection (e.g., id, name, email).

Database (DB) → A container for all collections.

HTTP Methods & Postman

POST → Sends data to the database (used for creating records).

GET → Fetches data from the database.

Postman → A tool to send requests to the backend and check responses.

Backend Function Calls

When we send a POST/GET request from Postman, it's like calling a function.

These functions must be defined in our backend (JS file).

The JS file acts as a medium that queries the database to store or retrieve data.

Postman is like a frontend where we send and request data.

Destructuring & Spread Operator in JavaScript
Destructuring
const obj = { name: "John Doe", email: "john@example.com" };
const { name, email } = obj;
console.log(name); // John Doe
console.log(email); // john@example.com

Makes it easier to access object properties directly.
Spread Operator (...)
const arr1 = [1, 2, 3, 4];
const arr2 = [5, 6];
const arr3 = [...arr1, ...arr2];
console.log(arr3); // [1, 2, 3, 4, 5, 6]

Combines multiple arrays/objects into one.

User Registration & Validations
Validations ensure that only correct data enters the database (e.g., email format, age limit).

When updating an entry, we need to explicitly enable validation:
runValidators: true

Timestamps (createdAt, updatedAt)

Track when a user registered and when they last updated their profile.

Platforms like Instagram use this to filter users based on registration date (e.g., last 7 days, 1 month).

Immutable Fields

Some fields cannot be changed after creation (e.g., emailID).

Must be enforced at the schema level.

API-Level Validation
API acts as a middleware between Postman (client) and the database (server).

API validation checks user data before sending it to the database to:

Avoid unnecessary DB calls (reducing cost & improving performance).

Enhance user experience by preventing delays.


This content originally appeared on DEV Community and was authored by yashi srivastava


Print Share Comment Cite Upload Translate Updates
APA

yashi srivastava | Sciencx (2025-04-02T22:11:30+00:00) Today’s Learning Update: Backend Basics. Retrieved from https://www.scien.cx/2025/04/02/todays-learning-update-backend-basics/

MLA
" » Today’s Learning Update: Backend Basics." yashi srivastava | Sciencx - Wednesday April 2, 2025, https://www.scien.cx/2025/04/02/todays-learning-update-backend-basics/
HARVARD
yashi srivastava | Sciencx Wednesday April 2, 2025 » Today’s Learning Update: Backend Basics., viewed ,<https://www.scien.cx/2025/04/02/todays-learning-update-backend-basics/>
VANCOUVER
yashi srivastava | Sciencx - » Today’s Learning Update: Backend Basics. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/04/02/todays-learning-update-backend-basics/
CHICAGO
" » Today’s Learning Update: Backend Basics." yashi srivastava | Sciencx - Accessed . https://www.scien.cx/2025/04/02/todays-learning-update-backend-basics/
IEEE
" » Today’s Learning Update: Backend Basics." yashi srivastava | Sciencx [Online]. Available: https://www.scien.cx/2025/04/02/todays-learning-update-backend-basics/. [Accessed: ]
rf:citation
» Today’s Learning Update: Backend Basics | yashi srivastava | Sciencx | https://www.scien.cx/2025/04/02/todays-learning-update-backend-basics/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.