<?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: Unwrap Solutions</title>
    <description>The latest articles on DEV Community by Unwrap Solutions (@unwrap_solutions_df68cc29).</description>
    <link>https://dev.to/unwrap_solutions_df68cc29</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%2F3007322%2F5e43a7fd-f698-4aaa-93e0-946ee8e91849.png</url>
      <title>DEV Community: Unwrap Solutions</title>
      <link>https://dev.to/unwrap_solutions_df68cc29</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/unwrap_solutions_df68cc29"/>
    <language>en</language>
    <item>
      <title>How to Enhance Prisma Queries with Filtering, Sorting, and Pagination</title>
      <dc:creator>Unwrap Solutions</dc:creator>
      <pubDate>Wed, 02 Apr 2025 11:59:19 +0000</pubDate>
      <link>https://dev.to/unwrap_solutions_df68cc29/how-to-enhance-prisma-queries-with-filtering-sorting-and-pagination-2h32</link>
      <guid>https://dev.to/unwrap_solutions_df68cc29/how-to-enhance-prisma-queries-with-filtering-sorting-and-pagination-2h32</guid>
      <description>&lt;p&gt;&lt;strong&gt;📌 Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Prisma is one of the best ORMs for Node.js and TypeScript. But when building APIs, we often need to:&lt;br&gt;
✅ Filter records dynamically&lt;br&gt;
✅ Sort results based on query parameters&lt;br&gt;
✅ Implement pagination for large datasets&lt;br&gt;
✅ Select only specific fields&lt;/p&gt;

&lt;p&gt;While Prisma provides built-in features, implementing these manually can become repetitive. That’s why I created Prisma Query Enhancer—a simple package to handle this efficiently.&lt;/p&gt;

&lt;p&gt;🚀 What is Prisma Query Enhancer?&lt;br&gt;
Prisma Query Enhancer is an NPM package that makes Prisma queries cleaner and more reusable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔧 Installation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sh&lt;br&gt;
npm install prisma-query-enhancer&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🛠️ How to Use It&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's say we need to fetch users with filtering, sorting, pagination, and selected fields. Here’s how Prisma Query Enhancer simplifies it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ts

import PrismaQueryEnhancer from 'prisma-query-enhancer';

const query = new PrismaQueryEnhancer(prisma.user, req.query)
  .filter()
  .sort()
  .limitFields()
  .paginate()
  .execute();

const users = await query;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🔥 No more boilerplate!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;📌 How It Works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;filter() → Removes unwanted query fields &amp;amp; applies filtering&lt;/li&gt;
&lt;li&gt;sort() → Sorts based on request parameters&lt;/li&gt;
&lt;li&gt;limitFields() → Selects only the necessary fields&lt;/li&gt;
&lt;li&gt;paginate() → Implements pagination&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;📦 Why Use Prisma Query Enhancer?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✔ Saves time by reducing boilerplate code&lt;br&gt;
✔ Works seamlessly with Prisma ORM&lt;br&gt;
✔ Handles complex queries effortlessly&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🚀 Try It Now!&lt;/strong&gt;&lt;br&gt;
📦 Install via NPM:&lt;/p&gt;

&lt;p&gt;`sh&lt;/p&gt;

&lt;p&gt;npm install prisma-query-enhancer`&lt;/p&gt;

&lt;p&gt;🔗 GitHub: &lt;a href="https://github.com/unwrapsolutions/prisma-query-enhancer" rel="noopener noreferrer"&gt;https://github.com/unwrapsolutions/prisma-query-enhancer&lt;/a&gt;&lt;br&gt;
🔗 NPM: &lt;a href="https://www.npmjs.com/package/prisma-query-enhancer" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/prisma-query-enhancer&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💬 Would love your feedback! Let me know what you think. 🚀&lt;/p&gt;

&lt;h1&gt;
  
  
  Prisma #TypeScript #NodeJS #WebDev #JavaScript #NPM #OpenSource
&lt;/h1&gt;

</description>
      <category>prisma</category>
      <category>typescript</category>
      <category>node</category>
      <category>npm</category>
    </item>
  </channel>
</rss>
