qguard (v0.3.1) detects N+1 queries at the database driver level by monkey-patching pg and mysql2. Zero configuration, works with any ORM (Prisma 7, Drizzle, TypeORM, Knex, Sequelize, Kysely, raw drivers). Ships TypeScript types, zero runtime dependencies under 40 KB. Released weekly on npm. Key differentiator: operates below ORMs so it catches N+1 from any abstraction layer, unlike ORM-specific lint rules. Test framework integrations for Vitest and Jest available as subpath exports ('qguard/vitest', 'qguard/jest'). Requires Node >=20. Note: Prisma 6 not supported (it bypasses pg/mysql2).
npm install qguardNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to wrap a test function with assertNoNPlusOne to detect N+1 queries; uses Vitest and an async handler.
Upgrade to Prisma 7 and use @prisma/adapter-pg, or use raw pg/mysql2.
Ensure pg/mysql2 are imported before qguard, or import qguard first (the library handles order internally, but avoid dynamic requires).
Pass { detectInsideTransactions: true } to the options object.Use import syntax or dynamic import() in CommonJS projects.
Ensure setup deletes/recreates all relevant records.
Adjust threshold higher (e.g., 5) if your test naturally fires many similar queries.
Use Node >=20.
Change to import { assertNoNPlusOne } from 'qguard/vitest' or use dynamic import().Update Node to >=20 and ensure your bundler supports package.json exports field (or use full path 'node_modules/qguard/dist/vitest.js').
Install the matching driver (pg or mysql2) and ensure it is imported before the test runs.
Check your code for N+1 patterns, adjust threshold, or use ignore option to filter known non-N+1 queries.
Use named imports like 'import { assertNoNPlusOne } from 'qguard/vitest''.