<?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>Forem: Mohammed Alfarra</title>
    <description>The latest articles on Forem by Mohammed Alfarra (@mohammadalfarra).</description>
    <link>https://forem.com/mohammadalfarra</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%2F336555%2F597c2304-8a40-47bb-9f1b-a72f4f87df9c.jpeg</url>
      <title>Forem: Mohammed Alfarra</title>
      <link>https://forem.com/mohammadalfarra</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mohammadalfarra"/>
    <language>en</language>
    <item>
      <title>Streamlining Filtering in NestJS</title>
      <dc:creator>Mohammed Alfarra</dc:creator>
      <pubDate>Thu, 26 Dec 2024 19:21:09 +0000</pubDate>
      <link>https://forem.com/mohammadalfarra/streamlining-filtering-in-nestjs-3439</link>
      <guid>https://forem.com/mohammadalfarra/streamlining-filtering-in-nestjs-3439</guid>
      <description>&lt;p&gt;If you’ve been working with NestJS for a while, you know the drill. You set up your services, build some endpoints, and — oh no — here comes the query filtering. Time to write yet another block of repetitive code just to let users filter data by name, date, status, or whatever else they need.&lt;/p&gt;

&lt;p&gt;Been there? Same. That’s exactly why &lt;a href="https://github.com/mohammed-alfarra/nestjs-filter" rel="noopener noreferrer"&gt;nestjs-filter&lt;/a&gt;, a package designed to make query filtering in NestJS so easy.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;A Tale of Too Many Filters!&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Every time you found yourself writing the same filtering logic over and over again. It was like that one chore you keep putting off but can’t avoid. 😅&lt;/p&gt;

&lt;p&gt;This worked, but it wasn’t fun, scalable, or particularly clever.🤷&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What Exactly Is &lt;a href="https://github.com/mohammed-alfarra/nestjs-filter" rel="noopener noreferrer"&gt;nestjs-filter&lt;/a&gt;? 🤔&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Great question! &lt;a href="https://github.com/mohammed-alfarra/nestjs-filter" rel="noopener noreferrer"&gt;nestjs-filter&lt;/a&gt; is like the personal assistant you wish you had for query filtering. Instead of manually writing all that boilerplate, you just plug it in, and it takes care of the rest. Here’s a sneak peek:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Inject&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Injectable&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@nestjs/common&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Product&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../model/product&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;GenericRepository&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;QueryParamsDto&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;nestjs-filter&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Injectable&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ProductService&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
 &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Inject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GENERIC_REPOSITORY&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;productRepository&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;GenericRepository&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Product&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
 &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;findAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;queryParams&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;QueryParamsDto&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;productRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findWithFilters&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;queryParams&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Boom. Done. No more boilerplate. 🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why You’ll Love It ❤️&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;So, what makes &lt;a href="https://github.com/mohammed-alfarra/nestjs-filter" rel="noopener noreferrer"&gt;nestjs-filter&lt;/a&gt; the secret sauce for your NestJS projects? Let me count the ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Less Boilerplate, More Happiness:&lt;/strong&gt; Forget writing the same if statements over and over again. Let &lt;a href="https://github.com/mohammed-alfarra/nestjs-filter" rel="noopener noreferrer"&gt;nestjs-filter&lt;/a&gt; handle it for you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flexible and Customizable:&lt;/strong&gt; Need something special? No problem! You can tweak it to fit your unique requirements.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keeps Your Code Clean 🧹:&lt;/strong&gt; Say goodbye to cluttered, spaghetti code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Ready to Try It? Let’s Go! 🚀&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/mohammed-alfarra/nestjs-filter" rel="noopener noreferrer"&gt;nestjs-filter&lt;/a&gt; is free and open-source, so you can dive right in. Head over to the GitHub repo, install it, and start building cleaner, smarter APIs.&lt;br&gt;
&lt;a href="https://github.com/mohammed-alfarra/nestjs-filter" rel="noopener noreferrer"&gt;Check out nestjs-filter on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Let’s Build Together! 🤝&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;I’d love to hear how you use &lt;a href="https://github.com/mohammed-alfarra/nestjs-filter" rel="noopener noreferrer"&gt;nestjs-filter&lt;/a&gt; in your projects. Got feedback? Found a bug? Or maybe you have an awesome idea for a new feature? Let’s chat! Together, we can make query filtering in NestJS a breeze for everyone.&lt;/p&gt;

&lt;p&gt;Happy coding! 🎉&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>nestjs</category>
      <category>filters</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
