Supported databases
Mask supports several database backends. The workflow is the same for all: configure mask.compile.cjs (overrideConfig), define models, write queries, run node mask.compile.cjs, and sync. The main difference is how you connect (the DB module export) and whether migrations are needed (SQL databases).
Common across all databases
- Project root
mask.compile.cjscallingrunWithMaskConfigwithoverrideConfigincludingdatabase,dbModulePath, andsyncApiKey. - Define models with
MaskModels.define('…')— works for SQL tables, MongoDB collections, or Neo4j graph descriptions. - Write queries with
MaskDatabase.prompt('…'), optionally usingregisteryinsideoverrideConfigformask-keys. - Run
node mask.compile.cjsto turn your definitions and prompts into runnable code.
Example overrideConfig (MongoDB)
{
"database": "mongodb",
"dbModulePath": "src/db",
"syncApiKey": "YOUR_PROJECT_API_KEY",
"modelPaths": ["src/tables.js"],
"queryPaths": ["src"]
}MongoDB summary
- database: "mongodb"
- DB export: getDB()
- No SQL migrations
Summary table
| Database | config database | DB export | Migrations |
|---|---|---|---|
| MongoDB | mongodb | getDB() | Not needed |
| Mongoose | mongoose | getMongooseConnection() | Not needed |
| MySQL | mysql | getSqlConnection() | npx mask-migrate |
| MariaDB | mariadb | getSqlConnection() | npx mask-migrate |
| PostgreSQL | postgres | getSqlConnection() | npx mask-migrate |
| SQLite | sqlite | getSqlConnection() | npx mask-migrate |
| Neo4j | neo4j | getNeo4jSession() | Not needed |
| Oracle | oracle | getSqlConnection() | npx mask-migrate |