Documentation
Mask is a natural-language database layer for Node.js. You describe models (schemas) and queries in plain English; the compiler turns them into database code for MongoDB, SQL, Neo4j, and more. At runtime there are no AI calls — everything is pre-compiled. Mask Databases stores and syncs compiled data per project so teams and deployment pipelines can share it.
To get started you only need two things: define your models with MaskModels.define('...') and run queries with MaskDatabase.prompt('...'). The generated code picks the right collections from the prompt automatically.
What Mask does
- Models — Call
MaskModels.define('User collection with name, email, teamId...'). The compiler turns that into a schema (collection name, fields, relations). Queries use that schema so field names and collections are always correct. - Queries — Call
MaskDatabase.prompt('find all users with status active')orMaskDatabase.prompt('mask-userById', { userId }). At runtime you callprompt()with the same string (and params) and get the result. No AI at runtime. - Compiling — Run
node mask.compile.cjs(ornode mask.compile.cjs --watchwhen your entry supports it) after you add or change models or queries. - Sync (Mask Databases) — Set
syncApiKeyinmask.compile.cjs(overrideConfig). Usemask-sync-fetchto get the latest andmask-sync-pushto share your changes.
Full feature set
| Feature | Description |
|---|---|
| Models | MaskModels.define('...') with collection, fields, and relations in natural language. Schemas can live in any file; the compiler finds all define() calls across your code. |
| Queries (inline) | MaskDatabase.prompt('find all users') — use the exact same string everywhere you need that query. |
| Queries (registery) | Put long prompts under registery in overrideConfig in mask.compile.cjs; in code use MaskDatabase.prompt('mask-key'). One source of truth, reuse across files. Details |
| Parameters | In prompt: :userId, :projectId. At runtime: MaskDatabase.prompt('...', { userId, projectId }). |
| Query types | Find, aggregation (joins/lookups), insert, update, delete — the compiler picks from your natural language. |
| MySQL/MariaDB note | When using mysql2, set multipleStatements: true in your SQL connection options so compiled write prompts that run multiple statements in one call work correctly. |
| getQueryForPrompt | See the generated query for a prompt without executing it — useful for debugging and verification. Details |
| getModelForPrompt | Inspect the compiled schema for a model without instantiating it — verify collection, fields, types, and relations. Details |
| driverOptions (MongoDB / Mongoose) | Describe extra driver behavior in your prompt at compile time (upsert, collation, returning full documents, etc.). Details |
| Legacy pass-through mode | For existing apps, you can provide exact schema/query code in prompts so compiled behavior stays aligned. See Models and Queries. |
| Compile | node mask.compile.cjs or node mask.compile.cjs --watch. Turns your models and queries into runnable code. |
| Sync | syncApiKey in mask.compile.cjs; mask-sync-fetch / mask-sync-push; dashboard to manage data. |
| Delete prompts | mask-delete — remove prompts from local files by hash, prompt text, or all failed prompts with --failed. Interactive shell or one-shot CLI. Details |
| DB module | Your app exports a connection function (e.g. getDB() for MongoDB) from a path set in dbModulePath. |
Getting started
Create an account, create a project, get your API key, and configure Mask.
Models
Define schemas in natural language with MaskModels.define(): collections, fields, and relations.
Queries
Write queries in plain language, use the prompt registery in mask.compile.cjs, pass parameters, and debug with getQueryForPrompt.
Compiling
When and how to run node mask.compile.cjs, watch mode, and how it fits with sync.
Configuration
mask.compile.cjs at project root: overrideConfig with database, DB module, API key, and optional scan paths. MySQL / MariaDB: set multipleStatements: true in your connection config.
Supported databases
MongoDB, Mongoose, MySQL, PostgreSQL, SQLite, Neo4j, Oracle — quick comparison and DB-specific setup.
Sync (fetch / push)
Use mask-sync-fetch to get the latest and mask-sync-push to share your changes across your team.
Dashboard
Sign in to create projects, copy API keys for syncApiKey, and manage your data.