<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vijaya kumar on Medium]]></title>
        <description><![CDATA[Stories by Vijaya kumar on Medium]]></description>
        <link>https://medium.com/@vijaykumard2000?source=rss-3458810a20d6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*szyGAn1jF2NcFVVi</url>
            <title>Stories by Vijaya kumar on Medium</title>
            <link>https://medium.com/@vijaykumard2000?source=rss-3458810a20d6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:02:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vijaykumard2000/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Python and MySQL CRUD Operations: A Complete Guide]]></title>
            <link>https://medium.com/@vijaykumard2000/python-and-mysql-crud-operations-a-complete-guide-e7f7cdd4d70b?source=rss-3458810a20d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7f7cdd4d70b</guid>
            <dc:creator><![CDATA[Vijaya kumar]]></dc:creator>
            <pubDate>Mon, 23 Dec 2024 06:51:52 GMT</pubDate>
            <atom:updated>2024-12-23T06:51:52.056Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, we’ll explore how to perform CRUD (Create, Read, Update, Delete) operations using Python with a MySQL database. CRUD operations are fundamental to any application that manages data, and Python’s versatile libraries make it an excellent choice for database manipulation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dJKtvdVknwT98VzRztmdxQ.jpeg" /></figure><h3>Prerequisites</h3><p>Before we dive into the code, ensure the following tools are installed on your system:</p><ol><li><strong>Python</strong>: Version 3.6 or higher.</li><li><strong>MySQL Server</strong>: Ensure MySQL is running and accessible.</li><li><strong>MySQL Connector</strong>: Python library to connect to MySQL. Install it using pip:</li></ol><pre>pip install mysql-connector-python</pre><h3>Setting Up the Database</h3><p>Create a MySQL database and a table to work with. For this tutorial, we’ll use a database named testdb and a table named users.</p><h3>SQL Script to Create Database and Table</h3><pre>CREATE DATABASE testdb;<br>USE testdb;</pre><pre>CREATE TABLE users (<br>    id INT AUTO_INCREMENT PRIMARY KEY,<br>    name VARCHAR(100) NOT NULL,<br>    email VARCHAR(100) UNIQUE NOT NULL,<br>    age INT NOT NULL<br>);</pre><h3>Python Code for CRUD Operations</h3><p>Here’s how to perform CRUD operations using Python:</p><h3>1. Connecting to MySQL Database</h3><pre>import mysql.connector</pre><pre># Establish a connection<br>connection = mysql.connector.connect(<br>    host=&quot;localhost&quot;,<br>    user=&quot;root&quot;,  # Replace with your MySQL username<br>    password=&quot;password&quot;,  # Replace with your MySQL password<br>    database=&quot;testdb&quot;<br>)</pre><pre># Check if the connection is successful<br>if connection.is_connected():<br>    print(&quot;Connected to MySQL database&quot;)</pre><h3>2. Create Operation</h3><p>Insert a new user into the users table.</p><pre>def create_user(name, email, age):<br>    cursor = connection.cursor()<br>    query = &quot;&quot;&quot;<br>    INSERT INTO users (name, email, age) VALUES (%s, %s, %s)<br>    &quot;&quot;&quot;<br>    cursor.execute(query, (name, email, age))<br>    connection.commit()<br>    print(f&quot;User {name} added successfully.&quot;)</pre><pre># Example Usage<br>create_user(&quot;John Doe&quot;, &quot;john.doe@example.com&quot;, 30)</pre><h3>3. Read Operation</h3><p>Retrieve all users from the users table.</p><pre>def read_users():<br>    cursor = connection.cursor()<br>    query = &quot;SELECT * FROM users&quot;<br>    cursor.execute(query)<br>    for row in cursor.fetchall():<br>        print(row)</pre><pre># Example Usage<br>read_users()</pre><h3>4. Update Operation</h3><p>Update a user’s details based on their ID.</p><pre>def update_user(user_id, name=None, email=None, age=None):<br>    cursor = connection.cursor()<br>    updates = []<br>    if name:<br>        updates.append(f&quot;name = &#39;{name}&#39;&quot;)<br>    if email:<br>        updates.append(f&quot;email = &#39;{email}&#39;&quot;)<br>    if age:<br>        updates.append(f&quot;age = {age}&quot;)<br>    <br>    if updates:<br>        query = f&quot;UPDATE users SET {&#39;, &#39;.join(updates)} WHERE id = {user_id}&quot;<br>        cursor.execute(query)<br>        connection.commit()<br>        print(f&quot;User with ID {user_id} updated successfully.&quot;)</pre><pre># Example Usage<br>update_user(1, name=&quot;John Smith&quot;, age=35)</pre><h3>5. Delete Operation</h3><p>Delete a user from the users table by ID.</p><pre>def delete_user(user_id):<br>    cursor = connection.cursor()<br>    query = &quot;DELETE FROM users WHERE id = %s&quot;<br>    cursor.execute(query, (user_id,))<br>    connection.commit()<br>    print(f&quot;User with ID {user_id} deleted successfully.&quot;)</pre><pre># Example Usage<br>delete_user(1)</pre><h3>Closing the Connection</h3><p>Always close the database connection after completing the operations.</p><pre>connection.close()<br>if not connection.is_connected():<br>    print(&quot;MySQL connection closed.&quot;)</pre><h3>Complete Code</h3><p>Here is the full code combining all the operations:</p><pre>import mysql.connector</pre><pre># Connect to MySQL<br>def connect_to_db():<br>    return mysql.connector.connect(<br>        host=&quot;localhost&quot;,<br>        user=&quot;root&quot;,<br>        password=&quot;password&quot;,<br>        database=&quot;testdb&quot;<br>    )</pre><pre>connection = connect_to_db()</pre><pre># Create Operation<br>def create_user(name, email, age):<br>    cursor = connection.cursor()<br>    query = &quot;INSERT INTO users (name, email, age) VALUES (%s, %s, %s)&quot;<br>    cursor.execute(query, (name, email, age))<br>    connection.commit()</pre><pre># Read Operation<br>def read_users():<br>    cursor = connection.cursor()<br>    query = &quot;SELECT * FROM users&quot;<br>    cursor.execute(query)<br>    return cursor.fetchall()</pre><pre># Update Operation<br>def update_user(user_id, name=None, email=None, age=None):<br>    cursor = connection.cursor()<br>    updates = []<br>    if name:<br>        updates.append(f&quot;name = &#39;{name}&#39;&quot;)<br>    if email:<br>        updates.append(f&quot;email = &#39;{email}&#39;&quot;)<br>    if age:<br>        updates.append(f&quot;age = {age}&quot;)<br>    if updates:<br>        query = f&quot;UPDATE users SET {&#39;, &#39;.join(updates)} WHERE id = {user_id}&quot;<br>        cursor.execute(query)<br>        connection.commit()</pre><pre># Delete Operation<br>def delete_user(user_id):<br>    cursor = connection.cursor()<br>    query = &quot;DELETE FROM users WHERE id = %s&quot;<br>    cursor.execute(query, (user_id,))<br>    connection.commit()</pre><pre># Closing the connection<br>connection.close()</pre><h3>Conclusion</h3><p>In this tutorial, we explored how to set up a MySQL database and perform CRUD operations using Python. By mastering these basics, you’re equipped to handle data manipulation tasks in real-world applications. Feel free to expand this example by adding exception handling, input validation, or integrating it into a web application framework like Flask or Django.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7f7cdd4d70b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a GraphQL CRUD API with MVC Pattern in Nodejs]]></title>
            <link>https://medium.com/@vijaykumard2000/building-a-graphql-crud-api-with-mvc-pattern-in-nodejs-07f3df95b3d9?source=rss-3458810a20d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/07f3df95b3d9</guid>
            <dc:creator><![CDATA[Vijaya kumar]]></dc:creator>
            <pubDate>Sat, 21 Dec 2024 10:52:50 GMT</pubDate>
            <atom:updated>2024-12-21T10:52:50.420Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iD-OPM_LlPtxsfCdSV-Lrw.jpeg" /></figure><p>In this tutorial, we will build a <strong>GraphQL CRUD API</strong> using the <strong>MVC (Model-View-Controller)</strong> pattern in <strong>Node.js</strong>. This approach ensures a clean structure, scalability, and maintainability for larger projects.</p><h3>Directory Structure</h3><pre>graphql-mvc-crud/<br>├── controllers/<br>│   └── userController.js<br>├── models/<br>│   └── userModel.js<br>├── graphql/<br>│   ├── schema.js<br>│   └── resolvers.js<br>├── app.js<br>└── package.json</pre><h3>1. Install Dependencies</h3><p>First, install the necessary packages for the project:</p><pre>npm install express express-graphql graphql mongoose</pre><h3>2. Model: userModel.js</h3><p>Define the Mongoose schema and model for the User.</p><pre>const mongoose = require(&#39;mongoose&#39;);<br><br>const userSchema = new mongoose.Schema({<br>  name: String,<br>  email: String,<br>  age: Number,<br>});<br><br>const User = mongoose.model(&#39;User&#39;, userSchema);<br><br>module.exports = User;</pre><h3>3. Controller: userController.js</h3><p>Handle the logic for database operations.</p><pre>const User = require(&#39;../models/userModel&#39;);<br><br>const userController = {<br>  getUsers: async () =&gt; await User.find(),<br>  getUser: async (id) =&gt; await User.findById(id),<br>  createUser: async (input) =&gt; {<br>    const user = new User(input);<br>    return await user.save();<br>  },<br>  updateUser: async (id, input) =&gt; {<br>    return await User.findByIdAndUpdate(id, input, { new: true });<br>  },<br>  deleteUser: async (id) =&gt; {<br>    await User.findByIdAndDelete(id);<br>    return &#39;User deleted successfully&#39;;<br>  },<br>};<br><br>module.exports = userController;</pre><h3>4. GraphQL Schema and Resolvers</h3><h4>Schema: schema.js</h4><p>Define the GraphQL schema.</p><pre>const { buildSchema } = require(&#39;graphql&#39;);<br><br>const schema = buildSchema(`<br>  type User {<br>    id: ID<br>    name: String<br>    email: String<br>    age: Int<br>  }<br><br>  type Query {<br>    getUsers: [User]<br>    getUser(id: ID!): User<br>  }<br><br>  input UserInput {<br>    name: String<br>    email: String<br>    age: Int<br>  }<br><br>  type Mutation {<br>    createUser(input: UserInput): User<br>    updateUser(id: ID!, input: UserInput): User<br>    deleteUser(id: ID!): String<br>  }<br>`);<br><br>module.exports = schema;</pre><h4>Resolvers: resolvers.js</h4><p>Connect the schema to the controller methods.</p><pre>const userController = require(&#39;../controllers/userController&#39;);<br><br>const resolvers = {<br>  getUsers: async () =&gt; await userController.getUsers(),<br>  getUser: async ({ id }) =&gt; await userController.getUser(id),<br>  createUser: async ({ input }) =&gt; await userController.createUser(input),<br>  updateUser: async ({ id, input }) =&gt; await userController.updateUser(id, input),<br>  deleteUser: async ({ id }) =&gt; await userController.deleteUser(id),<br>};<br><br>module.exports = resolvers;</pre><h3>5. Main Application: app.js</h3><p>Set up the Express server and connect everything.</p><pre>const express = require(&#39;express&#39;);<br>const mongoose = require(&#39;mongoose&#39;);<br>const { graphqlHTTP } = require(&#39;express-graphql&#39;);<br>const schema = require(&#39;./graphql/schema&#39;);<br>const resolvers = require(&#39;./graphql/resolvers&#39;);<br><br>const app = express();<br><br>// MongoDB connection<br>mongoose.connect(&#39;mongodb://localhost:27017/graphql-mvc&#39;, {<br>  useNewUrlParser: true,<br>  useUnifiedTopology: true,<br>}).then(() =&gt; console.log(&#39;Connected to MongoDB&#39;))<br>  .catch((err) =&gt; console.error(&#39;Database connection error:&#39;, err));<br><br>// GraphQL middleware<br>app.use(&#39;/graphql&#39;, graphqlHTTP({<br>  schema,<br>  rootValue: resolvers,<br>  graphiql: true,<br>}));<br><br>app.listen(4000, () =&gt; {<br>  console.log(&#39;Server is running on http://localhost:4000/graphql&#39;);<br>});</pre><h3>Testing Queries and Mutations</h3><blockquote>1. Create a User</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p5yw_rTZxfDDgvWpTcUjTg.png" /></figure><blockquote>2. Get All Users</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bOHFFrslXNirZDUff0nGMg.png" /></figure><blockquote>3. Get a Single User</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nlNsEfimxsI9xIHSim0RQg.png" /></figure><blockquote>4. Update a User</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3YOodaiLa-Se4eNNw2bEng.png" /></figure><blockquote>5. Delete a User</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sNU3CjdosFFRho3C3Tyx3g.png" /></figure><h3>Advantages of Using MVC with GraphQL</h3><ol><li><strong>Separation of Concerns</strong>: The controller handles logic, while the model deals with the database.</li><li><strong>Scalability</strong>: Easily extend the application by adding new resolvers or models.</li><li><strong>Maintainability</strong>: Clean and structured code for larger projects.</li><li><strong>Flexibility</strong>: GraphQL’s dynamic query structure allows clients to fetch only the required data.</li></ol><p>This structure ensures your GraphQL API is robust, maintainable, and ready for complex features. Start building and let me know if you need further enhancements or optimizations!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=07f3df95b3d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to perform CRUD operations using Sequelize in Node.js]]></title>
            <link>https://medium.com/@vijaykumard2000/how-to-perform-crud-operations-using-sequelize-in-node-js-cc3d0f46ec47?source=rss-3458810a20d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc3d0f46ec47</guid>
            <dc:creator><![CDATA[Vijaya kumar]]></dc:creator>
            <pubDate>Fri, 02 Aug 2024 06:24:12 GMT</pubDate>
            <atom:updated>2024-08-02T06:24:12.403Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X7ncnrbZIsrPW6zArM1L2A.jpeg" /></figure><p><strong>Introduction:</strong></p><p>Sequelize is a promise-based Node.js ORM for SQL databases like MySQL, PostgreSQL, SQLite, and MSSQL. It features solid transaction support, relations, eager and lazy loading, read replication, and more. In this blog post, we’ll walk through how to set up a Node.js application using Sequelize ORM to perform CRUD (Create, Read, Update, Delete) operations.</p><blockquote>Step 1: Setting Up the Project</blockquote><p>First, let’s create a new Node.js project and install the required dependencies.</p><pre>mkdir sequelize-crud<br>cd sequelize-crud<br>npm init -y<br>npm install express sequelize mysql2</pre><blockquote>Step 2: Setting Up Sequelize</blockquote><p>Create a new folder structure for your project:</p><pre>sequelize-crud/<br>│<br>├── config/<br>│   └── database.js<br>├── models/<br>│   └── index.js<br>│   └── user.js<br>├── routes/<br>│   └── userRoutes.js<br>├── controllers/<br>│   └── userController.js<br>└── app.js</pre><blockquote>Step 3: Configure the Database</blockquote><p>Create the config/database.js file to configure the database connection:</p><pre>const { Sequelize } = require(&#39;sequelize&#39;);<br><br>const sequelize = new Sequelize(&#39;database_name&#39;, &#39;username&#39;, &#39;password&#39;, {<br>  host: &#39;localhost&#39;,<br>  dialect: &#39;mysql&#39;<br>});<br><br>module.exports = sequelize;</pre><p>Replace database_name, username, and password with your actual database credentials.</p><blockquote>Step 4: Define the User Model</blockquote><p>Create models/user.js to define the User model:</p><pre>const { DataTypes } = require(&#39;sequelize&#39;);<br>const sequelize = require(&#39;../config/database&#39;);<br><br>const User = sequelize.define(&#39;User&#39;, {<br>  id: {<br>    type: DataTypes.INTEGER,<br>    primaryKey: true,<br>    autoIncrement: true<br>  },<br>  name: {<br>    type: DataTypes.STRING,<br>    allowNull: false<br>  },<br>  email: {<br>    type: DataTypes.STRING,<br>    allowNull: false,<br>    unique: true<br>  }<br>});<br><br>module.exports = User;</pre><blockquote>Step 5: Initialize Models</blockquote><p>Create models/index.js to initialize Sequelize and sync the models:</p><pre>const sequelize = require(&#39;../config/database&#39;);<br>const User = require(&#39;./user&#39;);<br><br>const db = {};<br>db.Sequelize = sequelize;<br>db.User = User;<br><br>db.Sequelize.sync()<br>  .then(() =&gt; console.log(&#39;Database synced&#39;))<br>  .catch((err) =&gt; console.log(&#39;Error syncing database&#39;, err));<br><br>module.exports = db;</pre><blockquote>Step 6: Create User Routes</blockquote><p>Create routes/userRoutes.js to define the CRUD routes for the User model:</p><pre>const express = require(&#39;express&#39;);<br>const router = express.Router();<br>const userController = require(&#39;../controllers/userController&#39;);<br><br>router.post(&#39;/users&#39;, userController.createUser);<br>router.get(&#39;/users&#39;, userController.getAllUsers);<br>router.get(&#39;/users/:id&#39;, userController.getUserById);<br>router.put(&#39;/users/:id&#39;, userController.updateUser);<br>router.delete(&#39;/users/:id&#39;, userController.deleteUser);<br><br>module.exports = router;</pre><blockquote>Step 7: Create User Controller</blockquote><p>Create controllers/userController.js to handle the logic for CRUD operations:</p><pre>const db = require(&#39;../models&#39;);<br>const User = db.User;<br><br>exports.createUser = async (req, res) =&gt; {<br>  try {<br>    const user = await User.create(req.body);<br>    res.status(201).json(user);<br>  } catch (err) {<br>    res.status(500).json({ error: err.message });<br>  }<br>};<br><br>exports.getAllUsers = async (req, res) =&gt; {<br>  try {<br>    const users = await User.findAll();<br>    res.status(200).json(users);<br>  } catch (err) {<br>    res.status(500).json({ error: err.message });<br>  }<br>};<br><br>exports.getUserById = async (req, res) =&gt; {<br>  try {<br>    const user = await User.findByPk(req.params.id);<br>    if (user) {<br>      res.status(200).json(user);<br>    } else {<br>      res.status(404).json({ error: &#39;User not found&#39; });<br>    }<br>  } catch (err) {<br>    res.status(500).json({ error: err.message });<br>  }<br>};<br><br>exports.updateUser = async (req, res) =&gt; {<br>  try {<br>    const [updated] = await User.update(req.body, {<br>      where: { id: req.params.id }<br>    });<br>    if (updated) {<br>      const updatedUser = await User.findByPk(req.params.id);<br>      res.status(200).json(updatedUser);<br>    } else {<br>      res.status(404).json({ error: &#39;User not found&#39; });<br>    }<br>  } catch (err) {<br>    res.status(500).json({ error: err.message });<br>  }<br>};<br><br>exports.deleteUser = async (req, res) =&gt; {<br>  try {<br>    const deleted = await User.destroy({<br>      where: { id: req.params.id }<br>    });<br>    if (deleted) {<br>      res.status(204).json();<br>    } else {<br>      res.status(404).json({ error: &#39;User not found&#39; });<br>    }<br>  } catch (err) {<br>    res.status(500).json({ error: err.message });<br>  }<br>};</pre><blockquote>Step 8: Create the Main Application File</blockquote><p>Create app.js to set up the Express application:</p><pre>const express = require(&#39;express&#39;);<br>const app = express();<br>const userRoutes = require(&#39;./routes/userRoutes&#39;);<br><br>app.use(express.json());<br>app.use(&#39;/api&#39;, userRoutes);<br><br>const PORT = process.env.PORT || 3000;<br>app.listen(PORT, () =&gt; {<br>  console.log(`Server is running on port ${PORT}`);<br>});</pre><blockquote>Step 9: Run the Application</blockquote><p>Start your application by running:</p><pre>node app.js</pre><p>Now you have a Node.js application using Sequelize ORM to perform CRUD operations on a MySQL database. You can test the CRUD operations using tools like Postman.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc3d0f46ec47" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding MongoDB Aggregation.]]></title>
            <link>https://medium.com/@vijaykumard2000/understanding-mongodb-aggregation-88470075f84c?source=rss-3458810a20d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/88470075f84c</guid>
            <dc:creator><![CDATA[Vijaya kumar]]></dc:creator>
            <pubDate>Fri, 02 Aug 2024 05:31:50 GMT</pubDate>
            <atom:updated>2024-08-02T05:31:50.391Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rd-ONkWGgoqjg2x2yxLXxg.jpeg" /></figure><p><strong>Introduction to Aggregation:</strong></p><p>Aggregation in MongoDB is a powerful tool that allows you to process data records and return computed results. It’s akin to combining data from multiple documents and performing operations like filtering, grouping, sorting, and transforming to get the desired results.</p><p><strong>The Aggregation Pipeline:</strong></p><p>MongoDB uses an <strong>aggregation pipeline</strong> to accomplish this. Think of the pipeline as a series of stages, where each stage transforms the data and passes the results to the next stage. It’s like an assembly line in a factory, where each step adds value to the final product.</p><p><strong>Common Aggregation Stages:</strong></p><p>Here are some common stages in the aggregation pipeline, explained with simple examples:</p><blockquote>$match</blockquote><p>The $match stage filters documents to pass only those that match the specified condition(s).</p><pre>{ $match: { status: &quot;active&quot; } }</pre><blockquote>$group</blockquote><p>The $group stage groups documents by a specified field and can perform operations like sum, average, count, etc.</p><pre>{ $group: { _id: &quot;$status&quot;, total: { $sum: 1 } } }</pre><blockquote>$project</blockquote><p>The $project stage reshapes documents by including, excluding, or adding new fields.</p><pre>{ $project: { name: 1, status: 1, year: { $year: &quot;$createdAt&quot; } } }</pre><blockquote>$sort</blockquote><p>The $sort stage sorts documents by a specified field.</p><pre>{ $sort: { createdAt: -1 } }</pre><blockquote>$limit</blockquote><p>The $limit stage limits the number of documents to pass through to the next stage.</p><pre>{ $limit: 5 }</pre><p><strong>Example Scenario:</strong></p><p>To make it more relatable, let’s imagine a real-world example: you have a collection of students’ records, and you want to find the average score of students in each grade.</p><p><strong>Sample Aggregation Query</strong></p><p>Let’s walk through a sample aggregation query step-by-step:</p><pre>[<br>  { $match: { score: { $gt: 0 } } },  // Stage 1: Filter out students with a score greater than 0<br>  { $group: { _id: &quot;$grade&quot;, avgScore: { $avg: &quot;$score&quot; } } },  // Stage 2: Group by grade and calculate the average score<br>  { $sort: { avgScore: -1 } }  // Stage 3: Sort grades by average score in descending order<br>]</pre><p><strong>Hands-On Practice</strong></p><p>To solidify your understanding, try practicing with these tasks:</p><ul><li>Find the total number of students in each grade.</li><li>Calculate the maximum and minimum scores in each grade.</li><li>Filter students who have a score above a certain threshold and then group them by grade.</li></ul><p><strong>Recap and Q&amp;A</strong></p><p>To wrap up, let’s summarize the key points:</p><ul><li><strong>Aggregation</strong> helps in transforming and analyzing data.</li><li>The <strong>aggregation pipeline</strong> is a series of stages.</li><li>Common stages include $match, $group, $project, $sort, and $limit.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88470075f84c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Merging PDFs into a Single Document Using Nodejs & Express]]></title>
            <link>https://medium.com/@vijaykumard2000/merging-pdfs-into-a-single-document-using-nodejs-express-02ad4af79774?source=rss-3458810a20d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/02ad4af79774</guid>
            <dc:creator><![CDATA[Vijaya kumar]]></dc:creator>
            <pubDate>Wed, 20 Mar 2024 13:15:25 GMT</pubDate>
            <atom:updated>2024-03-20T13:15:25.690Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sENZhoVUtgwr37DyvUkb7Q.jpeg" /></figure><blockquote>Introduction:</blockquote><p>In today’s fast-paced digital world, efficiency is key. Whether you’re managing business documents, academic papers, or personal files, having the ability to merge multiple PDFs into a single document can significantly streamline your workflow. In this blog post, we’ll explore various methods and tools for merging PDF files, helping you save time and stay organized.</p><p>Start by creating an express application using the below code.</p><pre>npm init -y</pre><p>And install the dependencies using the below code.</p><pre>npm i pdf-lib</pre><p>And create index.js in the current folder.</p><pre>const fs = require(&#39;fs&#39;);<br>const path = require(&#39;path&#39;);<br>const { PDFDocument } = require(&#39;pdf-lib&#39;);<br><br><br>async function mergePDFs(pdfPaths, outputPath) {<br>    const mergedPdf = await PDFDocument.create();<br><br>    for (const pdfPath of pdfPaths) {<br>        const pdfBytes = fs.readFileSync(pdfPath);<br>        const pdf = await PDFDocument.load(pdfBytes);<br>        const copiedPages = await mergedPdf.copyPages(pdf, pdf.getPageIndices());<br>        copiedPages.forEach(page =&gt; mergedPdf.addPage(page));<br>    }<br><br>    const mergedPdfBytes = await mergedPdf.save();<br>    fs.writeFileSync(outputPath, mergedPdfBytes);<br><br>    return outputPath;<br>}<br><br>async function mergeAndSavePDFs(pdfPaths, outputPath) {<br>    try {<br>        const mergedFileName = await mergePDFs(pdfPaths, outputPath);<br>        console.log(&#39;PDFs merged successfully. Merged file saved at:&#39;, mergedFileName);<br>        return mergedFileName;<br>    } catch (error) {<br>        console.error(&#39;Error merging PDFs:&#39;, error);<br>        throw error;<br>    }<br>}<br><br>// Example usage<br>const pdfPaths = [<br>    &#39;example1.pdf&#39;,<br>    &#39;example2.pdf&#39;,<br>    // Add more PDF paths as needed<br>];<br>const outputPath = &#39;new.pdf&#39;;<br><br>mergeAndSavePDFs(pdfPaths, outputPath)<br>    .then(mergedFileName =&gt; {<br>        console.log(mergedFileName)<br>    })<br>    .catch(error =&gt; {<br>       console.log(error)<br>    });</pre><p>And start the server using the below code.</p><pre>node index.js</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=02ad4af79774" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PowerBI: Turning Data into Smart Decisions]]></title>
            <link>https://medium.com/@vijaykumard2000/powerbi-turning-data-into-smart-decisions-8683c0bbaefd?source=rss-3458810a20d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/8683c0bbaefd</guid>
            <category><![CDATA[power-bi-tutorials]]></category>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[what-is-power-bi]]></category>
            <dc:creator><![CDATA[Vijaya kumar]]></dc:creator>
            <pubDate>Mon, 11 Mar 2024 11:37:01 GMT</pubDate>
            <atom:updated>2024-03-11T11:37:01.521Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MEFftmoAZE5rXzbmYJNGQg.png" /></figure><p>Imagine having a super tool that helps you make sense of your data easily. That’s PowerBI! It’s like magic for businesses, turning boring numbers into colorful charts that tell a story.</p><blockquote>Seeing is Believing</blockquote><p>PowerBI lets you create cool charts and dashboards. It’s like turning a messy room into a tidy one so that everyone can find what they need. This helps big bosses and teams make decisions faster because they see what’s happening in their business.</p><blockquote>Friends with All Your Data</blockquote><p>PowerBI is friendly. It gets along with all your data, no matter where it lives. It’s like a superhero that brings all your data together — from spreadsheets, the internet, or even secret data hideouts. This means you always have the latest info at your fingertips.</p><blockquote>Ask Anything, Get Smart Answers</blockquote><p>Here’s the cool part: PowerBI understands questions you ask, even if you talk like a regular person. You can say, “Hey PowerBI, show me sales from last month,” and it magically does it. This makes it easy for everyone, even if they’re not data experts.</p><blockquote>Teamwork Makes the Dream Work</blockquote><p>With PowerBI, everyone on your team can work together. Imagine a giant digital board where everyone puts sticky notes with their thoughts. That’s what PowerBI does — it helps teams share ideas, comment on stuff, and decide things together.</p><blockquote>Your Data, Anytime, Anywhere</blockquote><p>PowerBI is like a genie that puts your data in your pocket. It has special apps for your phone, so you can check things even when you’re not at your desk. It’s like carrying your office in your pocket!</p><blockquote>The Final Word</blockquote><p>PowerBI isn’t just a tool; it’s like having a smart friend who helps you understand your business better. It turns data into your secret weapon for making awesome decisions. So, if you’re in the business game, having PowerBI on your team is like having a superpower for success! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8683c0bbaefd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Node.js and MongoDB Pagination]]></title>
            <link>https://medium.com/@vijaykumard2000/mastering-node-js-and-mongodb-pagination-27145cbefbcd?source=rss-3458810a20d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/27145cbefbcd</guid>
            <dc:creator><![CDATA[Vijaya kumar]]></dc:creator>
            <pubDate>Sat, 02 Mar 2024 05:31:47 GMT</pubDate>
            <atom:updated>2024-03-02T05:31:47.279Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mHA0yj1kvHxW8-5Wf_OhWA.png" /></figure><p>Implementing pagination for User content in a Node.js application with MongoDB involves several steps. Below is a basic example using Express for the server and Mongoose for MongoDB interaction. This example assumes that you have a user model in your MongoDB database.</p><blockquote>Prerequisites:</blockquote><p>Ensure you have Node.js and MongoDB installed on your machine.</p><blockquote><strong>Install Dependencies:</strong></blockquote><pre>npm install express mongoose</pre><blockquote>Create Your Express App:</blockquote><pre>const express = require(&#39;express&#39;);<br>const mongoose = require(&#39;mongoose&#39;);<br>const app = express();<br>const PORT = 3000;<br><br>// Connect to MongoDB<br>mongoose.connect(&#39;mongodb://127.0.0.1:27017/new&#39;, { useNewUrlParser: true, useUnifiedTopology: true });<br><br>// Create a User model<br>const User = mongoose.model(&#39;users&#39;, {<br>  userId: Number,<br>  title: String,<br>  id: Number,<br>  completed: Boolean,<br>});<br><br>// Express middleware to parse JSON<br>app.use(express.json());<br><br>// Route to get paginated User posts<br>app.get(&#39;/users&#39;, async (req, res) =&gt; {<br>  const page = parseInt(req.query.page) || 1;<br>  const limit = parseInt(req.query.limit) || 10;<br><br>  try {<br>    //count document<br>    const count=await User.countDocuments()<br>    //find the User<br>    const user = await User.find()<br>      .skip((page - 1) * limit)<br>      .limit(limit);<br>      //total count<br>      const totalPages = Math.ceil(count / limit);<br>      // Validate current page<br>      if (page &lt; 1 || page &gt; totalPages) {<br>        return res.status(400).json({ message: &#39;Invalid page number&#39; });<br>      }<br><br>    res.json({<br>      page,limit,count, totalPages,user<br>    });<br>  } catch (error) {<br>    res.status(500).json({ message: &#39;Error fetching User&#39;, error: error.message });<br>  }<br>});<br><br>// Start the server<br>app.listen(PORT, () =&gt; {<br>  console.log(`Server is running on http://localhost:${PORT}`);<br>});</pre><blockquote>Testing the Pagination:</blockquote><ul><li>Run your Node.js application.</li><li>Use tools like <a href="https://www.postman.com/">Postman</a> or <a href="https://curl.se/">curl</a> to make requests to your /users endpoint with different page and limit parameters.</li></ul><blockquote>Example Request:</blockquote><pre>http://localhost:3000/blogs?page=2&amp;limit=10</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*yE_3sSQIB-cVcLCsKKddhA.png" /></figure><blockquote>Conclusion</blockquote><p>Mastering pagination in Node.js and MongoDB is a fundamental skill for any web developer aiming to build scalable and performant applications. With the right techniques and best practices, you can create applications that handle large datasets gracefully, providing users with a smooth and responsive experience.</p><p>Embark on this journey to harness the power of Node.js and MongoDB pagination, and elevate your web development skills to new heights!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27145cbefbcd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How do I become the MERN stack developer?]]></title>
            <link>https://medium.com/@vijaykumard2000/how-do-i-become-the-mern-stack-developer-034556a9060b?source=rss-3458810a20d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/034556a9060b</guid>
            <dc:creator><![CDATA[Vijaya kumar]]></dc:creator>
            <pubDate>Wed, 14 Feb 2024 12:50:16 GMT</pubDate>
            <atom:updated>2024-02-14T12:50:16.804Z</atom:updated>
            <content:encoded><![CDATA[<h3>How do I become the MERN stack developer? What are the necessary skills for an MERN stack developer?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yj_gzY-9gIF4fS-wUxcJlg.png" /></figure><h3>Introduction:</h3><p>Becoming a MERN (MongoDB, Express.js, React, Node.js) stack developer involves acquiring a set of skills across both the front-end and back-end technologies. Here are the necessary skills and steps to become a MERN stack developer</p><h3>Front-End Development:</h3><p><strong>React.js:</strong></p><ul><li>Understand components, props, state, and React Router.</li><li>Explore state management with Redux or Context API.</li><li>Learn about hooks for functional components.</li></ul><h3>Back-End Development:</h3><p><strong>Node.js and Express.js:</strong></p><ul><li>Understand the basics of Node.js and its event-driven, non-blocking architecture.</li><li>Learn to build RESTful APIs with Express.js.</li></ul><h3>Database:</h3><p><strong>MongoDB:</strong></p><ul><li>Learn MongoDB, a NoSQL database.</li><li>Understand concepts like documents, collections, and basic queries.</li><li>Learn to interact with MongoDB using Mongoose (Node.js library).</li></ul><h3>APIs and HTTP/REST:</h3><ul><li>Understand the principles of HTTP and RESTful API design.</li><li>Learn how to create, read, update, and delete (CRUD) operations in your API.</li></ul><h3>Authentication and Authorization:</h3><ul><li>Implement user authentication using JWT (JSON Web Tokens).</li><li>Understand authorization mechanisms.</li></ul><h3>Learn a Version Control System:</h3><p>Understand the basics of version control using Git and GitHub.</p><h3>Conclusion:</h3><p>Remember, becoming proficient in a full-stack involves consistent practice and hands-on experience. Take your time with each technology, understand its principles, and build projects to reinforce your learning. Additionally, staying engaged with the developer community and keeping up with industry trends is essential for continuous improvement.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=034556a9060b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connecting Node.js and MySQL: A Simple Guide for Robust Applications]]></title>
            <link>https://medium.com/@vijaykumard2000/connecting-node-js-and-mysql-a-simple-guide-for-robust-applications-8ac32278a56d?source=rss-3458810a20d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ac32278a56d</guid>
            <dc:creator><![CDATA[Vijaya kumar]]></dc:creator>
            <pubDate>Thu, 01 Feb 2024 05:30:25 GMT</pubDate>
            <atom:updated>2024-02-01T05:30:25.009Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZXvG2Qc5vDCumoyb5OSXYQ.png" /></figure><h3>Introduction:</h3><p>In the world of web development, Node.js is like a superhero that helps build fast and efficient server-side applications. When paired with MySQL, a powerful database, you get a dynamic duo capable of creating robust and scalable applications. Let’s dive into a straightforward guide that explains how to connect Node.js and MySQL, making your applications powerful and reliable.</p><h3>Prerequisites:</h3><ol><li>Ensure you have Node.js installed on your machine.</li><li>Set up a MySQL database and create a table named users with columns id, name, and email.</li></ol><pre>--create Database<br>CREATE DATABASE user;<br>--use the database<br>USE user;<br>--create the table<br>CREATE TABLE IF NOT EXISTS users (<br>  id INT AUTO_INCREMENT PRIMARY KEY,<br>  name VARCHAR(255) NOT NULL,<br>  email VARCHAR(255) NOT NULL<br>);</pre><p>Start by creating an express application using the below code.</p><pre>npm init -y</pre><p>And install the dependencies using the below code.</p><pre>npm install express mysql2<br>(or)<br>npm i express mysql2</pre><p>We need to run a web server in order to make our API endpoint accessible to the browser or a tool like PostMan. We will be using Express JS to achieve this. If you are not familiar with ExpressJS, head to the<a href="https://expressjs.com/"> official website </a>to learn more; otherwise, let’s keep going. With npm, we install Express in our project with this command.</p><p>And create index.js in the current folder.</p><pre>// import express<br>const express = require(&#39;express&#39;);<br>// import mysql<br>const mysql = require(&#39;mysql2/promise&#39;);<br>// initialise the app<br>const app = express();<br>const port = 3000;<br><br>// MySQL Connection Pool<br>const pool = mysql.createPool({<br>  host: &#39;localhost&#39;,<br>  user: &#39;your-mysql-user&#39;,<br>  password: &#39;your-mysql-password&#39;,<br>  database: &#39;user&#39;,<br>  connectionLimit: 10<br>});<br><br>// use json request in postman<br>app.use(express.json());<br><br>// Create a user<br>app.post(&#39;/users&#39;, async (req, res) =&gt; {<br>  try {<br>    const { name, email } = req.body;<br>    const [result] = await pool.query(&#39;INSERT INTO users (name, email) VALUES (?, ?)&#39;, [name, email]);<br>    res.json({ id: result.insertId, name, email });<br>  } catch (error) {<br>    console.error(error);<br>    res.status(500).json({ error: &#39;Internal Server Error&#39; });<br>  }<br>});<br><br>// Read all users<br>app.get(&#39;/users&#39;, async (req, res) =&gt; {<br>  try {<br>    const [rows] = await pool.query(&#39;SELECT * FROM users&#39;);<br>    res.json(rows);<br>  } catch (error) {<br>    console.error(error);<br>    res.status(500).json({ error: &#39;Internal Server Error&#39; });<br>  }<br>});<br><br>// Read a user by ID<br>app.get(&#39;/users/:id&#39;, async (req, res) =&gt; {<br>  try {<br>    const { id } = req.params;<br>    const [rows] = await pool.query(&#39;SELECT * FROM users WHERE id = ?&#39;, [id]);<br>    if (rows.length === 0) {<br>      res.status(404).json({ error: &#39;User not found&#39; });<br>    } else {<br>      res.json(rows[0]);<br>    }<br>  } catch (error) {<br>    console.error(error);<br>    res.status(500).json({ error: &#39;Internal Server Error&#39; });<br>  }<br>});<br><br>// Update a user by ID<br>app.put(&#39;/users/:id&#39;, async (req, res) =&gt; {<br>  try {<br>    const { id } = req.params;<br>    const { name, email } = req.body;<br>    const [result] = await pool.query(&#39;UPDATE users SET name = ?, email = ? WHERE id = ?&#39;, [name, email, id]);<br>    if (result.affectedRows === 0) {<br>      res.status(404).json({ error: &#39;User not found&#39; });<br>    } else {<br>      res.json({ id: parseInt(id), name, email });<br>    }<br>  } catch (error) {<br>    console.error(error);<br>    res.status(500).json({ error: &#39;Internal Server Error&#39; });<br>  }<br>});<br><br>// Delete a user by ID<br>app.delete(&#39;/users/:id&#39;, async (req, res) =&gt; {<br>  try {<br>    const { id } = req.params;<br>    const [result] = await pool.query(&#39;DELETE FROM users WHERE id = ?&#39;, [id]);<br>    if (result.affectedRows === 0) {<br>      res.status(404).json({ error: &#39;User not found&#39; });<br>    } else {<br>      res.json({ message: &#39;User deleted successfully&#39; });<br>    }<br>  } catch (error) {<br>    console.error(error);<br>    res.status(500).json({ error: &#39;Internal Server Error&#39; });<br>  }<br>});<br><br>// Start the server<br>app.listen(port, () =&gt; {<br>  console.log(`Server is running on port ${port}`);<br>});</pre><p>And start the server using the below code.</p><pre>node index.js</pre><p>And then, check the APIs in Postman.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*-SF_Vi5RKERKXOC1cY0-Jw.png" /></figure><p>Verify if the data has been created in the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OZLNNbvs7F4aGPi5izKHvw.png" /></figure><p>By the end of this guide, you’ll have a comprehensive understanding of connecting Node.js with MySQL, empowering you to build robust and efficient applications that harness the strengths of both technologies. Let’s embark on this journey to master the art of Node.js and MySQL integration!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ac32278a56d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Node.js and MongoDB Connection: A Comprehensive Guide]]></title>
            <link>https://medium.com/@vijaykumard2000/mastering-node-js-and-mongodb-connection-a-comprehensive-guide-70a9e4504974?source=rss-3458810a20d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/70a9e4504974</guid>
            <dc:creator><![CDATA[Vijaya kumar]]></dc:creator>
            <pubDate>Wed, 31 Jan 2024 11:24:39 GMT</pubDate>
            <atom:updated>2024-01-31T11:24:39.223Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DT1Fq3Lu_dTLa4TA5n9IMA.png" /></figure><h3>Introduction:</h3><p>In the realm of web development, the seamless integration of databases is paramount. Node.js, a powerful runtime for server-side JavaScript, paired with MongoDB, a NoSQL database, forms a dynamic duo for building robust and scalable applications. In this guide, we’ll explore the intricacies of establishing and managing a connection between Node.js and MongoDB.</p><p>First of all, verify that Node.js and MongoDB are installed on the local machine.</p><p>Start by creating an express application using the below code.</p><pre>npm init -y</pre><p>And install the dependencies using the below code.</p><pre>npm install express mongoose <br>(or)<br>npm i express mongoose</pre><p>We need to run a web server in order to make our API endpoint accessible to the browser or a tool like PostMan. We will be using Express JS to achieve this. If you are not familiar with ExpressJS, head to the<a href="https://expressjs.com/"> official website </a>to learn more; otherwise, let’s keep going. With npm, we install Express in our project with this command.</p><p>Mongoose is a Node.js package for modelling MongoDB. It helps you handle validation and business logic for MongoDB on Node.js. You can learn more <a href="http://mongoosejs.com/">here</a>.</p><p>And create index.js in the current folder.</p><pre>// import express<br>const express = require(&#39;express&#39;);<br>// initialise the app<br>const app = express();<br>// import mongoose<br>const mongoose = require(&#39;mongoose&#39;);<br>// local db URL<br>const url = &#39;mongodb://127.0.0.1/image&#39;;<br>// use json request in postman<br>app.use(express.json());<br>// Connect to Mongoose and set connection variable<br>mongoose.connect(url, { useUnifiedTopology: true, useNewUrlParser: true });<br>const con = mongoose.connection;<br>con.on(&#39;open&#39;, () =&gt; {<br>    console.log(&#39;database connection....&#39;);<br>});<br><br>// Define a mongoose schema for a simple &quot;Image&quot; model<br>const imageSchema = new mongoose.Schema({<br>    name: String,<br>    url: String<br>});<br><br>// Create a mongoose model based on the schema<br>const Image = mongoose.model(&#39;Image&#39;, imageSchema);<br><br>// Create operation<br>app.post(&#39;/images&#39;, async (req, res) =&gt; {<br>    const { name, url } = req.body;<br>    const newImage = new Image({ name, url });<br>    try {<br>        const savedImage = await newImage.save();<br>        res.json(savedImage);<br>    } catch (error) {<br>        res.status(500).json({ error: error.message });<br>    }<br>});<br><br>// Read operation<br>app.get(&#39;/images&#39;, async (req, res) =&gt; {<br>    try {<br>        const images = await Image.find();<br>        res.json(images);<br>    } catch (error) {<br>        res.status(500).json({ error: error.message });<br>    }<br>});<br><br>// Update operation<br>app.put(&#39;/images/:id&#39;, async (req, res) =&gt; {<br>    const { id } = req.params;<br>    const { name, url } = req.body;<br>    try {<br>        const updatedImage = await Image.findByIdAndUpdate(id, { name, url }, { new: true });<br>        res.json(updatedImage);<br>    } catch (error) {<br>        res.status(500).json({ error: error.message });<br>    }<br>});<br><br>// Delete operation<br>app.delete(&#39;/images/:id&#39;, async (req, res) =&gt; {<br>    const { id } = req.params;<br>    try {<br>        const deletedImage = await Image.findByIdAndDelete(id);<br>        res.json(deletedImage);<br>    } catch (error) {<br>        res.status(500).json({ error: error.message });<br>    }<br>});<br><br>// Send message for default URL<br>app.get(&#39;/&#39;, (req, res) =&gt; {<br>    res.send(&#39;Successfully Connected....&#39;);<br>});<br><br>// Launch app to listen to specified port<br>app.listen(1111, () =&gt; console.log(&#39;server connection...1111&#39;));</pre><p>And start the server using the below code.</p><pre>node index.js</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OOwcom7-BFqN1uXMxu58sw.png" /></figure><p>Let’s try with the browser. Visit <a href="http://localhost:1111/">http://localhost:1111</a>you should get this screen</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*cufV94gsGXThchT6rbxuoA.png" /></figure><p>Then you can check the crud operation using Postman and check the data in MongoDB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*y5scRooGYzyPHKKGxdvUwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mL-ieP31wFwXfVkHI0R3fg.png" /></figure><p>By the end of this guide, you’ll have a comprehensive understanding of connecting Node.js with MongoDB, enabling you to build robust and efficient applications that leverage the strengths of both technologies. Let’s embark on this journey to master the art of Node.js and MongoDB integration!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70a9e4504974" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>