Choose Your Adapter
filter-def is split into multiple packages. Install only the adapters you need for your project:@filter-def/in-memory
For filtering JavaScript arrays with native methods
@filter-def/drizzle
For generating SQL WHERE clauses with Drizzle ORM
@filter-def/bigquery
For creating parameterized BigQuery SQL queries
@filter-def/core
Core types only (usually not needed directly)
Installation Commands
In-Memory Filtering
For filtering arrays in JavaScript/TypeScript applications:@filter-def/in-memory has zero runtime dependencies except for @filter-def/core (bundled automatically).Drizzle ORM Adapter
For SQL databases using Drizzle ORM:Requires
drizzle-orm@>=0.30.0 as a peer dependency. You’ll also need a database driver (e.g., pg for PostgreSQL, better-sqlite3 for SQLite).BigQuery Adapter
For Google BigQuery parameterized SQL queries:@google-cloud/bigquery@>=7.0.0 is an optional peer dependency. The adapter can generate SQL without it, but you’ll need it to execute queries.Core Package (Optional)
The core package contains TypeScript types and utilities. It’s automatically included when you install any adapter, but you can install it directly if you’re building a custom adapter:Package Versions
All packages use semantic versioning. Check npm for the latest versions:TypeScript Configuration
filter-def requires TypeScript 5.0 or later with strict mode enabled. Add these settings to yourtsconfig.json:
tsconfig.json
Installing Multiple Adapters
You can install multiple adapters in the same project. This is useful for:- Using different backends for different features
- Testing in-memory before deploying to a database
- Supporting multiple data sources (e.g., PostgreSQL + BigQuery)
Verify Installation
Test your installation with a simple example:index.ts
Peer Dependencies
Each adapter has specific peer dependency requirements:@filter-def/in-memory
@filter-def/in-memory
No peer dependenciesWorks out of the box with no additional packages required.
@filter-def/drizzle
@filter-def/drizzle
Required:
drizzle-orm@>=0.30.0
- PostgreSQL:
pgorpostgres - MySQL:
mysql2 - SQLite:
better-sqlite3
@filter-def/bigquery
@filter-def/bigquery
Optional:
@google-cloud/bigquery@>=7.0.0
Troubleshooting
Type errors with TypeScript
Type errors with TypeScript
Ensure you’re using TypeScript 5.0+ with strict mode:If you see errors about missing types, install the corresponding
tsconfig.json
@types packages:Module not found errors
Module not found errors
If you see “Cannot find module” errors:
-
Check that you installed the package:
-
Verify your
moduleResolutionsetting intsconfig.json: -
Clear your package manager cache:
Peer dependency warnings
Peer dependency warnings
Peer dependency warnings indicate missing or incompatible versions of required packages.For Drizzle:For BigQuery:If you’re not using a particular adapter, you can safely ignore its peer dependency warnings.
Next Steps
Quick Start Guide
Build your first filter in 5 minutes
API Reference
Explore all available filter types