Filter your API results with powerful comparison operators in NestJS CRUD
Filtering allows you to retrieve only the data that matches specific conditions. The NestJS CRUD framework provides a comprehensive set of operators for building simple to complex filters.
# Find users with status active or pendingGET /users?filter=status||$in||active,pending# Find users aged between 18 and 65GET /users?filter=age||$between||18,65# Find users not in guest or banned rolesGET /users?filter=role||$notin||guest,banned
# Find users with status "active" or "pending" (case-insensitive)GET /users?filter=status||$inL||active,PENDING# Matches: "Active", "PENDING", "active", "pending"
Values are automatically parsed to the correct type:
# Number/users?filter=age||eq||25 # value is number 25# Boolean/users?filter=isActive||eq||true # value is boolean true# Date/users?filter=createdAt||gt||2024-01-01T00:00:00.000Z # value is Date object# String/users?filter=name||eq||John # value is string "John"# Array/users?filter=id||in||1,2,3 # value is array [1, 2, 3]
# Find products in a price rangeGET /products?filter=price||gte||10&filter=price||lte||100# Find products by category and in stockGET /products?filter=category||eq||electronics&filter=stock||gt||0# Find products with specific tagsGET /products?filter=tags||in||sale,featured,new
# Find active users created this yearGET /users?filter=isActive||eq||true&filter=createdAt||gte||2024-01-01# Find users by roleGET /users?filter=role||in||admin,moderator# Find unverified usersGET /users?filter=emailVerified||eq||false
Invalid filters will throw a RequestQueryException:
# Invalid operatorGET /users?filter=name||invalid||John# Error: Invalid comparison operator# Missing value for non-null operatorGET /users?filter=name||eq# Error: Invalid filter value# Invalid field formatGET /users?filter=||eq||John# Error: Invalid field type in filter condition