{"id":43853,"library":"snack-query-builder","title":"Snack Query Builder","description":"Snack Query Builder is a lightweight, type-safe SQL query builder for TypeScript/JavaScript that generates SQL strings programmatically without being an ORM. It provides a fluent API for building SELECT queries with projection, WHERE conditions (including comparisons like greaterOrEqualThan), GROUP BY, HAVING, subqueries, and TOP clauses. Version 1.0.4 is the latest stable release, published on npm with TypeScript type definitions included. Unlike ORMs such as TypeORM or Sequelize, it does not abstract away SQL or manage database connections; it simply constructs raw SQL strings. Ideal for developers who want full control over their SQL while benefiting from TypeScript's type checking.","status":"active","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/ariassd/snack-query-builder","tags":["javascript","SQL","Node","Query","Generator","typescript"],"install":[{"cmd":"npm install snack-query-builder","lang":"bash","label":"npm"},{"cmd":"yarn add snack-query-builder","lang":"bash","label":"yarn"},{"cmd":"pnpm add snack-query-builder","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package exports from the 'dist' subfolder; importing from the root may not resolve.","wrong":"import { SnackQueryBuilder } from 'snack-query-builder';","symbol":"SnackQueryBuilder","correct":"import { SnackQueryBuilder } from 'snack-query-builder/dist';"},{"note":"CommonJS require works but must include '/dist'; ESM import is the recommended approach for TypeScript.","wrong":"const Aggregation = require('snack-query-builder').Aggregation;","symbol":"Aggregation","correct":"import { Aggregation } from 'snack-query-builder/dist';"},{"note":"Used for terminal-colored SQL output; optional.","wrong":null,"symbol":"Colorful","correct":"import { Colorful } from 'snack-query-builder/dist';"}],"quickstart":{"code":"import { SnackQueryBuilder, Aggregation, Colorful } from 'snack-query-builder/dist';\n\nconst query = new SnackQueryBuilder();\nquery\n  .from('users')\n  .select('id', 'name', 'email')\n  .where()\n  .greaterOrEqualThan(Aggregation.and, 'age', 18)\n  .end()\n  .orderBy('name');\n\nconsole.log(query.build(Colorful.Terminal));\n// Output:\n// select\n//         id,\n//         name,\n//         email\n// from    users\n// where   age >= '18'\n// order by name","lang":"typescript","description":"Builds a SELECT query with projection, WHERE condition, and ordering, then prints the generated SQL."},"warnings":[{"fix":"Use 'import { ... } from 'snack-query-builder/dist';' instead of from 'snack-query-builder'.","message":"Import must use '/dist' path","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Cast numeric values to strings before passing; consider using parameterized queries separately.","message":"Values in WHERE conditions are always wrapped in quotes as strings","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use raw SQL strings or another library for complex queries; snack-query-builder only covers SELECT basics.","message":"No support for JOINs, UNIONs, or subqueries beyond fromSubQuery","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.4':52 'abstract':76 'api':31 'away':77 'benefit':100 'build':33 'builder':3,6,15 'check':105 'claus':50 'comparison':41 'condit':39 'connect':82 'construct':85 'control':95 'databas':81 'definit':64 'develop':91 'fluent':30 'full':94 'generat':19,110 'greaterorequalthan':43 'group':44 'ideal':89 'includ':40,65 'javascript':106 'latest':55 'lightweight':9 'like':42 'manag':80 'node':108 'npm':60 'orm':26,67 'programmat':22 'project':37 'provid':28 'publish':58 'queri':2,5,14,35,109 'raw':86 'releas':57 'safe':12 'select':34 'sequel':72 'simpli':84 'snack':1,4 'sql':13,20,78,87,98,107 'stabl':56 'string':21,88 'subqueri':47 'top':49 'type':11,63,104 'type-saf':10 'typeorm':70 'typescript':62,102,111 'typescript/javascript':17 'unlik':66 'version':51 'want':93 'without':23","created_at":"2026-06-05T17:01:47.543256+00:00","updated_at":"2026-06-05T17:01:47.543256+00:00","problems":[{"fix":"Ensure import path is 'snack-query-builder/dist'.","cause":"Missing '/dist' in import path","error":"Cannot find module 'snack-query-builder'"},{"fix":"Add .end() to close the WHERE (or HAVING) clause before calling .build().","cause":"Chaining incomplete; forgot .end() after .where()","error":"Property 'build' does not exist on type 'SnackQueryBuilder'"},{"fix":"Always start with new SnackQueryBuilder() and call .from() before other methods.","cause":"Misordering methods; .from() must be called first","error":"TypeError: query.from is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/ariassd/snack-query-builder#readme","github":"https://github.com/ariassd/snack-query-builder","docs":null,"changelog":null,"pypi":null,"npm":"snack-query-builder","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}