Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
parseQuery
✓ import { parseQuery } from 'qast'
✗ const qast = require('qast'); const parseQuery = qast.parseQuery;
ESM-only since v2; CommonJS require with destructuring is not supported. Use ESM imports.
toPrismaFilter
✓ import { toPrismaFilter } from 'qast'
Available since v1. Ensure @prisma/client is installed as a peer dependency.
toSequelizeFilter
✓ import { toSequelizeFilter } from 'qast'
Works with Sequelize v6+. Uses Op symbols internally.
parseQueryFull
✓ import { parseQueryFull } from 'qast'
✗ import { parseFull } from 'qast'
The correct name is 'parseQueryFull', not 'parseFull' or 'parseQueryFull' misspelled.
openApiFilterParameter
✓ import { openApiFilterParameter } from 'qast'
Generates OpenAPI 3.x query parameter spec. Only for filter strings, not full query.
Parse a filter query string into an AST and apply it as a Prisma where clause.
import { parseQuery, toPrismaFilter } from 'qast';
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
const raw = "age gt 25 and (name eq 'John' or city eq 'Paris')";
const ast = parseQuery(raw, {
allowedFields: ['age', 'name', 'city'],
validate: true,
});
const filter = toPrismaFilter(ast);
// filter: { AND: [ { age: { gt: 25 } }, { OR: [ { name: { equals: 'John' } }, { city: { equals: 'Paris' } } ] } ] }
const users = await prisma.user.findMany({ where: filter });
console.log(users);
// String literals must be quoted: 'single quotes' or "double quotes" are both valid.
// Numeric values are parsed as numbers.
// Booleans: true/false (unquoted).
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Using require('qast') in a CommonJS file with Node.js >=16.
fixUse import { parseQuery } from 'qast' in an ESM module, or use dynamic import: const qast = await import('qast'). TypeError: (0 , qast.toPrismaFilter) is not a function
Incorrect import or destructuring of a CommonJS default export.
fixUse import { toPrismaFilter } from 'qast' instead of const qast = require('qast'); qast.toPrismaFilter(). Error: Unknown operator 'gt'
The operator 'gt' is not in the allowedOperators list.
fixAdd 'gt' to allowedOperators in parseQuery options, or use a different operator.
Audit
Dependencies
@prisma/clientoptionalOptional peer dependency needed for Prisma adapter
drizzle-ormoptionalOptional peer dependency needed for Drizzle adapter
knexoptionalOptional peer dependency needed for Knex adapter
mongooseoptionalOptional peer dependency needed for Mongoose adapter
sequelizeoptionalOptional peer dependency needed for Sequelize adapter
typeormoptionalOptional peer dependency needed for TypeORM adapter