<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Masudur Rahman</title>
    <description>The latest articles on DEV Community by Masudur Rahman (@devmasud).</description>
    <link>https://dev.to/devmasud</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F777091%2F71a4d905-6348-4d04-af07-d09e1b718990.png</url>
      <title>DEV Community: Masudur Rahman</title>
      <link>https://dev.to/devmasud</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devmasud"/>
    <language>en</language>
    <item>
      <title>HTML</title>
      <dc:creator>Masudur Rahman</dc:creator>
      <pubDate>Mon, 23 May 2022 04:45:54 +0000</pubDate>
      <link>https://dev.to/devmasud/html-41hf</link>
      <guid>https://dev.to/devmasud/html-41hf</guid>
      <description>&lt;h2&gt;
  
  
  HTML Introduction
&lt;/h2&gt;

&lt;p&gt;HTML is a formatting system of our documents over the internet. It is a short form of &lt;em&gt;Hyper Text Markup Language&lt;/em&gt;. &lt;strong&gt;Mainly it gives the structure of Web Pages&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;British scientist Sir &lt;strong&gt;Tim Berners-Lee&lt;/strong&gt; first introduced with it at the CERN nuclear physics laboratory in Switzerland during the 1980s. &lt;/p&gt;

&lt;p&gt;HTML markup tags specify document elements such as &lt;strong&gt;headings, paragraphs, and tables&lt;/strong&gt;. They mark up a document for display by a computer program known as a &lt;strong&gt;Web browser&lt;/strong&gt;. The browser interprets the tags, displaying the headings, paragraphs, and tables in a layout that is adapted to the screen size and fonts available to it. Although it also contain &lt;em&gt;anchors&lt;/em&gt; which helps to hyperlink another web page. &lt;/p&gt;

&lt;p&gt;So, &lt;strong&gt;a marked-up document contains two types of text:&lt;/strong&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;text to be displayed and &lt;/li&gt;
&lt;li&gt;markup language on how to display it.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>html</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>CRUD MongoDB</title>
      <dc:creator>Masudur Rahman</dc:creator>
      <pubDate>Thu, 23 Dec 2021 16:35:10 +0000</pubDate>
      <link>https://dev.to/devmasud/crud-mongodb-2861</link>
      <guid>https://dev.to/devmasud/crud-mongodb-2861</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;CRUD&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In computer programming, &lt;strong&gt;create&lt;/strong&gt; , &lt;strong&gt;read&lt;/strong&gt; , &lt;strong&gt;update&lt;/strong&gt; , and &lt;strong&gt;delete&lt;/strong&gt; are the four basic operations of persistent storage. &lt;strong&gt;CRUD&lt;/strong&gt; is also sometimes used to describe user interface conventions that facilitate &lt;strong&gt;viewing&lt;/strong&gt; , &lt;strong&gt;searching&lt;/strong&gt; , and &lt;strong&gt;changing&lt;/strong&gt; information using computer-based forms and reports.&lt;/p&gt;

&lt;p&gt;To create a database in MongoDB, we have to start by creating a &lt;strong&gt;MongoClient object&lt;/strong&gt; , then specify a connection URL with the correct *&lt;em&gt;ip *&lt;/em&gt; address and the name of the database we want to create.&lt;/p&gt;

&lt;p&gt;MongoDB will create the database if it does not exist, and make a connection to it. &lt;strong&gt;For example-&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; var MongoClient = require('mongodb').MongoClient;
 var url = "mongodb://localhost:27017/mydb";

 MongoClient.connect(url, function(err, db) {
    if (err) throw err;
    console.log("Database created!");
    db.close();
 });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Second Step Collection&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To create a collection in MongoDB, use the &lt;strong&gt;createCollection()&lt;/strong&gt; method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create a collection called "customers":
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  var dbo = db.db("mydb");
  dbo.createCollection("customers", function(err, res) {
    if (err) throw err;
    console.log("Collection created!");
    db.close();
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Create&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;first letter of CRUD&lt;/strong&gt; , &lt;strong&gt;‘C’&lt;/strong&gt; , refers to &lt;strong&gt;CREATE&lt;/strong&gt; aka &lt;strong&gt;add&lt;/strong&gt; , &lt;strong&gt;insert&lt;/strong&gt; . Now insert a document in the "&lt;strong&gt;customers&lt;/strong&gt;" collection.To insert a record, or document as it is called in MongoDB, into a collection, we use the &lt;strong&gt;insertOne()&lt;/strong&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  var dbo = db.db("mydb");
  var myobj = { name: "Company Inc", address: "Highway 37" };
  dbo.collection("customers").insertOne(myobj, function(err, res) {
    if (err) throw err;
    console.log("1 document inserted");
    db.close();
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Find One&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To select data from a collection in MongoDB, we can use the &lt;strong&gt;findOne()&lt;/strong&gt; method. The findOne() method returns the first occurrence in the selection. The first parameter of the findOne() method is a query object. In this example we use an empty query object, which selects all documents in a collection (but returns only the first document).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  var dbo = db.db("mydb");
  dbo.collection("customers").findOne({}, function(err, result) {
    if (err) throw err;
    console.log(result.name);
    db.close();
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Delete Document&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To &lt;strong&gt;delete&lt;/strong&gt; a record, or document as it is called in MongoDB, we use the &lt;strong&gt;deleteOne()&lt;/strong&gt; method. The first parameter of the deleteOne() method is a query object defining which document to delete.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Delete the document with the address "Mountain 21":&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  var dbo = db.db("mydb");
  var myquery = { address: 'Mountain 21' };
  dbo.collection("customers").deleteOne(myquery, function(err, obj) {
    if (err) throw err;
    console.log("1 document deleted");
    db.close();
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Update Document&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;We can &lt;strong&gt;update&lt;/strong&gt; a record, or document as it is called in MongoDB, by using the &lt;strong&gt;updateOne()&lt;/strong&gt; method. The first parameter of the &lt;strong&gt;updateOne()&lt;/strong&gt; method is a query object defining which document to update.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Update the document with the address "Valley 345" to name="Mickey" and address="Canyon 123"&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://127.0.0.1:27017/";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  var dbo = db.db("mydb");
  var myquery = { address: "Valley 345" };
  var newvalues = { $set: {name: "Mickey", address: "Canyon 123" } };
  dbo.collection("customers").updateOne(myquery, newvalues, function(err, res) {
    if (err) throw err;
    console.log("1 document updated");
    db.close();
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Query&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Filter the Result&lt;/em&gt;&lt;br&gt;
When finding documents in a collection, we can filter the result by using a &lt;strong&gt;query&lt;/strong&gt; object. The first argument of the &lt;strong&gt;find()&lt;/strong&gt; method is a query object, and is &lt;strong&gt;used to limit the search&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Find documents with the address "Park Lane 38"&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  var dbo = db.db("mydb");
  var query = { address: "Park Lane 38" };
  dbo.collection("customers").find(query).toArray(function(err, result) {
    if (err) throw err;
    console.log(result);
    db.close();
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>insert</category>
      <category>delete</category>
      <category>update</category>
      <category>query</category>
    </item>
    <item>
      <title>React Hooks</title>
      <dc:creator>Masudur Rahman</dc:creator>
      <pubDate>Wed, 22 Dec 2021 12:13:12 +0000</pubDate>
      <link>https://dev.to/devmasud/react-hooks-5df3</link>
      <guid>https://dev.to/devmasud/react-hooks-5df3</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hooks&lt;/strong&gt; are basically &lt;strong&gt;functional components&lt;/strong&gt; of &lt;strong&gt;React&lt;/strong&gt;. It doesn't work inside &lt;strong&gt;classes&lt;/strong&gt;. They let us use React without classes. Now we will know about some &lt;strong&gt;basic&lt;/strong&gt; and &lt;strong&gt;additional&lt;/strong&gt; hooks.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Basic Hooks:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. useState():&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It returns a &lt;strong&gt;stateful value&lt;/strong&gt; and a function to &lt;strong&gt;update&lt;/strong&gt; it. For example- &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ej9e0Vbp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eiieaap3jqbzh0tx7wxs.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ej9e0Vbp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eiieaap3jqbzh0tx7wxs.JPG" alt="Image description" width="866" height="65"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In the above code,&lt;/strong&gt; the initial rendering of the returned state &lt;strong&gt;(state)&lt;/strong&gt; returned as the same value passed as the first argument &lt;strong&gt;(initialState)&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;And the &lt;strong&gt;setState&lt;/strong&gt; function is used to update the state where it belongs. It &lt;strong&gt;accepts&lt;/strong&gt; a new state value and enqueues a re-render of the component.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--djwpSDXB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yti6fmx56l7qd7sw33g3.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--djwpSDXB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yti6fmx56l7qd7sw33g3.JPG" alt="Image description" width="863" height="65"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. useEffect():&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Basically useEffect hook allows us to perform side effects  in our components. Such as: &lt;strong&gt;fetching data, directly updating the DOM and timer&lt;/strong&gt;. The useEffect hook accepts two arguments. Second argument is optional. For example- &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WOIxM14j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/66klcbtxvj2nk5g4pbvc.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WOIxM14j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/66klcbtxvj2nk5g4pbvc.JPG" alt="Image description" width="807" height="241"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. useContext():&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In React, Context is the &lt;strong&gt;way to manage state globally&lt;/strong&gt;. It accepts an object which returns from &lt;strong&gt;React.createContext&lt;/strong&gt; and returns the current context value for that context. Where current context value is determined by the value &lt;strong&gt;prop&lt;/strong&gt; of the nearest &lt;strong&gt;&lt;/strong&gt; below the calling component in the tree. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_QM-ZgE0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gv0lgfs95n3u8i5b57tt.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_QM-ZgE0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gv0lgfs95n3u8i5b57tt.JPG" alt="Image description" width="861" height="67"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It can be used together with the &lt;strong&gt;useState&lt;/strong&gt; Hook to share state between deeply nested components more easily than with useState alone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Additional Hooks:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;useReducer ()&lt;/li&gt;
&lt;li&gt;useCallback()&lt;/li&gt;
&lt;li&gt;useMemo()&lt;/li&gt;
&lt;li&gt;useRef()&lt;/li&gt;
&lt;li&gt;useImperativeHandle()&lt;/li&gt;
&lt;li&gt;useLayoutEffec()&lt;/li&gt;
&lt;li&gt;useDebugValue()&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;*&lt;em&gt;In my next blog I will discuss Additional Hooks briefly. *&lt;/em&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>usestate</category>
      <category>useeffect</category>
      <category>usecontext</category>
    </item>
  </channel>
</rss>
