<?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: Basit Raza</title>
    <description>The latest articles on DEV Community by Basit Raza (@basit_raza).</description>
    <link>https://dev.to/basit_raza</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%2F463486%2Fe2495fef-6fec-4fe2-8b6a-2f28f7f0822d.jpeg</url>
      <title>DEV Community: Basit Raza</title>
      <link>https://dev.to/basit_raza</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/basit_raza"/>
    <language>en</language>
    <item>
      <title>Answer: Why use `concat` instead of `push` in this instance?</title>
      <dc:creator>Basit Raza</dc:creator>
      <pubDate>Tue, 06 Oct 2020 09:54:43 +0000</pubDate>
      <link>https://dev.to/basit_raza/answer-why-use-concat-instead-of-push-in-this-instance-5afg</link>
      <guid>https://dev.to/basit_raza/answer-why-use-concat-instead-of-push-in-this-instance-5afg</guid>
      <description>&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;h1&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pTF_nE4a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/stackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
            &lt;a href="https://stackoverflow.com/questions/48428044/why-use-concat-instead-of-push-in-this-instance/64223425#64223425" rel="noopener noreferrer"&gt;
              &lt;span class="title-flare"&gt;answer&lt;/span&gt; re:  Why use `concat` instead of `push` in this instance?
            &lt;/a&gt;
        &lt;/h1&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Oct  6 '20&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/48428044/why-use-concat-instead-of-push-in-this-instance/64223425#64223425" rel="noopener noreferrer"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5MiFESHx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/stackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          0
        &lt;/div&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Rk_a5QFN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/stackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;In simple push append the array in the same reference, while concat doestn't effect the orignal array. Check out following snippet&lt;/p&gt;
&lt;div class="snippet" data-lang="js"&gt;
&lt;div class="snippet-code"&gt;
&lt;pre class="snippet-code-js lang-js prettyprint-override"&gt;&lt;code&gt;let x = [1,2,3,4];
let y = x.concat(5);
// At this step y hold [1,2,3,4,5] and x remain unchanged to [1,2,3,4]
document.write('x=&amp;gt;'+x);
document.write('y=&amp;gt;'+y);

let z = x.push(5);&lt;/code&gt;&lt;/pre&gt;…&lt;/div&gt;
&lt;/div&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    
      &lt;a href="https://stackoverflow.com/questions/48428044/why-use-concat-instead-of-push-in-this-instance/64223425#64223425" rel="noopener noreferrer"&gt;Open Full Answer&lt;/a&gt;
    
  &lt;/div&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Answer: Using Mongoose `pre` hook to get document before findOneAndUpdate()</title>
      <dc:creator>Basit Raza</dc:creator>
      <pubDate>Fri, 04 Sep 2020 13:06:43 +0000</pubDate>
      <link>https://dev.to/basit_raza/answer-using-mongoose-pre-hook-to-get-document-before-findoneandupdate-2f50</link>
      <guid>https://dev.to/basit_raza/answer-using-mongoose-pre-hook-to-get-document-before-findoneandupdate-2f50</guid>
      <description>&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;h1&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pTF_nE4a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/stackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
            &lt;a href="https://stackoverflow.com/questions/54579752/using-mongoose-pre-hook-to-get-document-before-findoneandupdate/54580544#54580544" rel="noopener noreferrer"&gt;
              &lt;span class="title-flare"&gt;answer&lt;/span&gt; re:  Using Mongoose `pre` hook to get document before findOneAndUpdate()
            &lt;/a&gt;
        &lt;/h1&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Feb  7 '19&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/54579752/using-mongoose-pre-hook-to-get-document-before-findoneandupdate/54580544#54580544" rel="noopener noreferrer"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5MiFESHx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/stackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          7
        &lt;/div&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Rk_a5QFN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/stackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;You can't retrieve the document in the &lt;code&gt;pre&lt;/code&gt; hook. &lt;/p&gt;

&lt;p&gt;According to the &lt;a href="https://mongoosejs.com/docs/middleware.html#notes" rel="noreferrer"&gt;documentation&lt;/a&gt; &lt;code&gt;pre&lt;/code&gt; is a query middleware and &lt;code&gt;this&lt;/code&gt; refers to the query and not the document being updated.&lt;/p&gt;

    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    
      &lt;a href="https://stackoverflow.com/questions/54579752/using-mongoose-pre-hook-to-get-document-before-findoneandupdate/54580544#54580544" rel="noopener noreferrer"&gt;Open Full Answer&lt;/a&gt;
    
  &lt;/div&gt;
&lt;/div&gt;


</description>
    </item>
  </channel>
</rss>
