<?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: Tonmoy Talukder</title>
    <description>The latest articles on DEV Community by Tonmoy Talukder (@tonmoytalukder).</description>
    <link>https://dev.to/tonmoytalukder</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%2F705335%2F26d7e9c0-4c86-4571-af52-ac571d3710bc.png</url>
      <title>DEV Community: Tonmoy Talukder</title>
      <link>https://dev.to/tonmoytalukder</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tonmoytalukder"/>
    <language>en</language>
    <item>
      <title>A Note on Mongoose &amp; MongoDB</title>
      <dc:creator>Tonmoy Talukder</dc:creator>
      <pubDate>Fri, 24 Dec 2021 07:14:47 +0000</pubDate>
      <link>https://dev.to/tonmoytalukder/a-note-on-mongoose-mongodb-2dno</link>
      <guid>https://dev.to/tonmoytalukder/a-note-on-mongoose-mongodb-2dno</guid>
      <description>&lt;p&gt;Mongoose is a JavaScript framework that is often used with a MongoDB database in Node.js applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is MongoDB?
&lt;/h2&gt;

&lt;p&gt;Let's have a look at MongoDB first. MongoDB is a database that keeps your information in the form of documents. Most of the time, these documents have a JSON-like structure:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{&lt;br&gt;
  firstName: "Jamie",&lt;br&gt;
  lastName: "Munro"&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
After that, a document is added to a collection. The document example above, for example, defines a user object. This user object would subsequently be included in a collection named users.&lt;/p&gt;

&lt;p&gt;MongoDB's versatility in terms of structure is one of its most important features. Despite the fact that the user object in the first example has a firstName and lastName field, these values are not necessary in every user document in the users collection. This distinguishes MongoDB from SQL databases such as MySQL or Microsoft SQL Server, which require each item to have a well-defined database structure.&lt;/p&gt;

&lt;p&gt;Mongoose comes into play when it comes to creating dynamic objects that are saved as documents in the database.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Mongoose?
&lt;/h2&gt;

&lt;p&gt;Mongoose is a Document Object Mapper (ODM). This implies Mongoose may construct objects with a strongly-typed schema that are mapped to MongoDB documents.&lt;/p&gt;

&lt;p&gt;Mongoose has a tremendous amount of capability for generating and dealing with schemas. When a property is persisted to MongoDB in Mongoose, it is stored as one of eight SchemaTypes. They are as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;String&lt;/li&gt;
&lt;li&gt;Number&lt;/li&gt;
&lt;li&gt;Date&lt;/li&gt;
&lt;li&gt;Buffer&lt;/li&gt;
&lt;li&gt;Boolean&lt;/li&gt;
&lt;li&gt;Mixed&lt;/li&gt;
&lt;li&gt;ObjectId&lt;/li&gt;
&lt;li&gt;Array&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each data type allows to specify:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a default value&lt;/li&gt;
&lt;li&gt;a custom validation function&lt;/li&gt;
&lt;li&gt;indicate a field is required&lt;/li&gt;
&lt;li&gt;a get function that allows you to manipulate the data before it is returned as an object&lt;/li&gt;
&lt;li&gt;a set function that allows you to manipulate the data before it is saved to the database&lt;/li&gt;
&lt;li&gt;create indexes to allow data to be fetched faster&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In addition to these standard settings, specific data types provide you even more control over how data is saved and retrieved from the database. A String data type, for example, enables you to define the following extra options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;convert it to lowercase&lt;/li&gt;
&lt;li&gt;convert it to uppercase&lt;/li&gt;
&lt;li&gt;trim data prior to saving&lt;/li&gt;
&lt;li&gt;a regular expression that can limit data allowed to be saved during the validation process&lt;/li&gt;
&lt;li&gt;an enum that can define a list of strings that are valid&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both the "Number" and "Date" attributes enable you to set a minimum and maximum value for a field.&lt;/p&gt;

&lt;p&gt;You should be acquainted with the majority of the eight data kinds that are permitted. However, you should be aware of a few exceptions, like "Buffer," "Mixed," "ObjectId," and "Array."&lt;/p&gt;

&lt;p&gt;Binary data may be saved using the "Buffer" data type. A picture or an encoded file, such as a PDF document, is a popular example of binary data.&lt;/p&gt;

&lt;p&gt;The "Mixed" data type transforms the property into a field where "anything goes." Because there is no standard structure, this variable reflects how many developers may use MongoDB. Use caution when using this data type since it disables several of Mongoose's fantastic capabilities, including data validation and detecting entity changes so that the property is immediately updated upon saving.&lt;/p&gt;

&lt;p&gt;The "ObjectId" data type is often used to indicate a connection to another document in your database. If you have a collection of books and authors, the book document may include a "ObjectId" attribute that references the document's particular author.&lt;/p&gt;

&lt;p&gt;You can store JavaScript-like arrays using the "Array" data type. You can execute typical JavaScript array operations on an Array data type, such as push, pop, shift, slice, and so on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summery
&lt;/h2&gt;

&lt;p&gt;MongoDB is a database that allows you to store documents with a dynamic structure. These documents are saved inside a collection.&lt;/p&gt;

&lt;p&gt;Mongoose is a JavaScript library that allows you to define schemas with strongly typed data. Once a schema is defined, Mongoose lets you create a Model based on a specific schema. A Mongoose Model is then mapped to a MongoDB Document via the Model's schema definition.&lt;/p&gt;

&lt;p&gt;Once you have defined your schemas and models, Mongoose contains many different functions that allow you to validate, save, delete, and query your data using common MongoDB functions.&lt;/p&gt;

</description>
      <category>tonmoytalukder</category>
      <category>mongodb</category>
      <category>mongoose</category>
      <category>node</category>
    </item>
    <item>
      <title>A Note on JSX</title>
      <dc:creator>Tonmoy Talukder</dc:creator>
      <pubDate>Fri, 24 Dec 2021 06:00:07 +0000</pubDate>
      <link>https://dev.to/tonmoytalukder/a-note-on-jsx-26kk</link>
      <guid>https://dev.to/tonmoytalukder/a-note-on-jsx-26kk</guid>
      <description>&lt;h2&gt;
  
  
  What is JSX?
&lt;/h2&gt;

&lt;p&gt;JSX is an XML-like syntax extension to ECMAScript that was introduced in 2013 with React and has no stated semantics. It is NOT designed for engines or browsers to implement. It is NOT a proposal to add JSX to the ECMAScript specification. It's designed to be utilized by different preprocessors (transpilers) to convert these tokens to ECMAScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  JSX Syntax
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;Page index="1"&amp;gt;&lt;br&gt;
  &amp;lt;h1&amp;gt;About me&amp;lt;/h1&amp;gt;&lt;br&gt;
  &amp;lt;AboutMe content={aboutMeContent} /&amp;gt;&lt;br&gt;
&amp;lt;/Page&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;transpiles to ⇒&lt;/p&gt;

&lt;p&gt;&lt;code&gt;React.createElement(&lt;br&gt;
  Page,&lt;br&gt;
  { "index": "1" },&lt;br&gt;
  React.createElement("h1", null, "About me"),&lt;br&gt;
  React.createElement(AboutMe, { content: aboutMeContent })&lt;br&gt;
);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;As we can see from the above example, JSX is an HTML-like syntax for creating JavaScript that is tied to the virtual DOM.&lt;br&gt;
Under the hood, JSX is converted to a virtual DOM.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why use JSX?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It has a low barrier to entry.&lt;/strong&gt; JSX is the closest thing we have to pure HTML and CSS right now. Without learning another templating language or dealing with various layers of abstraction, you can quickly include parts of JavaScript in your templates with JSX. Anyone who is acquainted with HTML, CSS, and JavaScript should be able to read and comprehend JSX templates with ease.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TypeScript support.&lt;/strong&gt; The compilation of TSX files with type-checking is supported by TypeScript. This implies that if you misspell an element's or attribute type's name, the compilation will fail and an error message will appear, pointing to your error. TSX files are also supported by popular IDEs like VS Code, which provide code completion, refactoring, and other important capabilities.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security.&lt;/strong&gt; To avoid attacks like cross-site scripting, JSX takes care of the standard output sanitization difficulties.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Difference between JS and JSX
&lt;/h2&gt;

&lt;p&gt;The JSX syntax is an HTML-like syntax that we can use with React to (theoretically) make creating React components simpler and more natural. The sole goal is to make creating React components simpler. There isn't much more to say. Creating huge, hierarchical HTML pages using JS syntax would be a pain in the neck without JSX; JSX merely simplifies the process.&lt;/p&gt;

</description>
      <category>tonmoytalukder</category>
      <category>javascript</category>
      <category>react</category>
      <category>jsx</category>
    </item>
  </channel>
</rss>
