New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dynamic-query-builder

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynamic-query-builder

build dynamic queries for ORMs

  • 2.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30
decreased by-92.59%
Maintainers
0
Weekly downloads
 
Created
Source

dynamic-query-builder

Prisma query builder

buildPrismaQuery Function

The buildPrismaQuery function builds a Prisma query based on flat filter conditions.

Mongoose query builder

buildMongooseQuery Function

The buildMongooseQuery function builds a Prisma query based on flat filter conditions.

Usage

This function takes an object of flat filter conditions and converts it into a Prisma-compatible query object. The filter conditions are expected to be in the format of field_condition: value, where field is the name of the field to filter on and condition is the type of filter to apply.

Supported Conditions
  • lt: Less than
  • lte: Less than or equal to
  • gt: Greater than
  • gte: Greater than or equal to
  • between: Between two values (requires an array with two values)
  • contains: Contains a value (case-insensitive)
  • c: Alias for contains
  • caseSensitiveContains: Contains a value (case-sensitive)
  • csc: Alias for caseSensitiveContains
  • ne: Not equal to
  • eq: Equal to
  • : Equal to (default condition)
  • neContains: Does not contain a value (case-insensitive)
  • nec: Alias for neContains
  • in: In a list of values
  • nin: Not in a list of values
Parameters
  • filters (Object): The flat filter conditions.
Returns
  • (Object): The Prisma-compatible query object.
Throws
  • Error: Throws an error if the between filter does not receive an array with two values.
Example
const filters = {
  age_gt: 30,
  name_contains: "John",
  status_in: ["active", "pending"],
};

const query = buildPrismaQuery(filters);
console.log(query);

Keywords

FAQs

Package last updated on 16 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc