MwalaJS is a lightweight and modular JavaScript framework designed for building scalable server-side applications using modern Node.js features. It follows the MVC (Model-View-Controller) pattern, making it easy to organize code for full-stack web applications. With built-in support for databases, routing, and middleware, MwalaJS accelerates development while keeping things simple and efficient.
Key Features:
Install MwalaJS globally to use CLI tools:
npm install -g mwalajs
If you're using it in a specific project, install locally:
npm install mwalajs
Note: In case of errors regarding missing fs-extra, install it manually:
npm install -g fs-extra
Note 2: MwalaJS is now an NPM package—no need to download .ZIP, .RAR, or .EXE files for versions 1.0.4 or above. Before creating a project, run npm init to create a package.json file. Ensure it includes:
"dependencies": {
"mwalajs": "^1.0.5"
},
"type": "module"
These settings are crucial before running mwala serve.
What You’ll Need:
mwalajs folder.C:\Program Files.C:\Program Files\mwalajs.mwala.unzip or tar -xvzf.sudo mv mwalajs /opt/sudo chmod +x /opt/mwalajs/mwala.mjssudo ln -s /opt/mwalajs/mwala.mjs /usr/local/bin/mwalamwala.| Issue | Solution |
|---|---|
mwala not recognized |
Recheck path, restart terminal |
| File won’t extract | Install 7-Zip or WinRAR |
| Node.js not found | Download from official site |
| Permission denied | Use sudo or check permissions |
Use the MwalaJS CLI to manage your projects efficiently. Run mwala help for a full list.
mwala create-project <projectName> → Create a new MVC project. mwala app.mjs → Start the main application file. Database Commands: - mwala create-db → Create database. - mwala create-table <name> → Create a table. - mwala drop-table <name> → Drop a table. - mwala migrate all → Run migrations. - mwala rollback all → Undo last migration. Code Generation: - mwala generate model <name> → Generate a model file. - mwala generate controller <name> → Generate a controller file. - mwala generate route <name> → Generate a route file. - mwala generate view <name> → Generate a view file. - mwala generate midware <name> → Generate middleware. mwala serve → Start local server. mwala help → List all available commands. mwala -v → Check version. mwala init → Initialize MwalaJS in a project.
| Command | Description |
|---|---|
mwala create-project <name> |
Create a new project |
mwala init |
Initialize MwalaJS |
mwala serve |
Run in development mode |
mwala help |
Display help |
mwala generate model <name> |
Generate model |
mwala generate controller <name> |
Generate controller |
mwala generate route <name> |
Generate route |
mwala generate view <name> |
Generate view |
mwala generate midware <name> |
Generate middleware |
mwala create-db |
Create database |
mwala create-table <name> |
Create table |
mwala drop-table <name> |
Drop table |
mwala migrate all |
Run all migrations |
mwala rollback all |
Undo migrations |
MwalaJS follows a standard MVC structure for organization. The main entry point is app.mjs (use .mjs for ES modules; fallback to .js if needed, but app.mjs is required as MwalaJS points to it).
In other folders, use filename.mjs or filename.js if .mjs causes errors.
mwalajs-project/
├── app.mjs # Main application entry point (must be .mjs)
├── migrations/ # Database migration files (e.g., migration001.js or .mjs)
├── models/ # Database models (e.g., UserModel.js or .mjs)
├── controllers/ # Application logic (e.g., UserController.js or .mjs)
├── routes/ # API routes (e.g., userRoutes.js or .mjs)
├── middlewares/ # Custom middleware (e.g., authMiddleware.js or .mjs)
├── config/ # Configuration files (e.g., database.js or .mjs, appSettings.js)
├── public/ # Static assets (CSS, JS, images)
│ ├── css/ # Stylesheets
│ ├── js/ # Client-side scripts
│ └── images/ # Images and icons
├── views/ # Template views for server-side rendering (e.g., index.html or .ejs)
├── package.json # NPM dependencies and scripts
└── README.md # Project documentation
Notes on File Extensions:
.mjs for modern ES modules..js except for app.mjs.controllers/UserController.mjs or UserController.js.Here are some code examples to get you started with MwalaJS.
// controllers/homeController.mjs
//homeController.mjs
export const homeController = {
getHomePage: (req, res) => {
res.render('index', { title: 'Welcome to MwalaJS MVC' });
}
};
export const Steps = {
getSteps: (req, res) => {
res.render('steps', { title: 'Welcome to MwalaJS MVC' });
}
};
export const welcome = {
getwelcome: (req, res) => {
res.render('welcome', { title: 'Welcome to MwalaJS MVC' });
}
};
export const about = {
getabout: (req, res) => {
res.render('about', { title: 'Welcome to MwalaJS MVC' });
}
};
// routes/homeRoutes.mjs
import mwalajs from 'mwalajs';
import { homeController,Steps,welcome,about } from '../controllers/homeController.mjs';
const router = mwalajs.Router(); // Corrected Router usage
router.get('/', homeController.getHomePage);
router.get('/steps',Steps.getSteps);
router.get('/welcome',welcome.getwelcome);
router.get('/about',about.getabout);
export { router as homeRoutes };
// app.mjs
//app.mjs
import mwalajs from 'mwalajs';
import { homeRoutes } from './routes/homeRoutes.mjs';
import { fileURLToPath } from 'url';
import path from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Use mwalajs directly (it's an instance now)
mwalajs.set('view engine', 'ejs');
mwalajs.set('views', path.join(__dirname, 'views'));
// Serve static files correctly
mwalajs.useStatic(path.join(__dirname, 'public'));
// Use routes
mwalajs.use('/', homeRoutes);
mwalajs.use('/steps', homeRoutes);
mwalajs.use('/about', homeRoutes);
mwalajs.use('/welcome', homeRoutes);
mwalajs.get('/mwalajs-framework-documentation', (req, res) => {
res.render('mwalajs-framework-documentation');
});
// Start server
const port = process.env.PORT || 2025;
mwalajs.listen(port, () => {
console.log(`Server running on http://localhost:${port}`);
});
Generating a Model
Run mwala generate model User to create a model file.
// models/User.mjs
export class User {
// Model logic here
}
EXAMPLE
import db from '../config/db.js';
export const getAllResources = async (filters = {}) => {
let query = `
SELECT r.*, u.fullname AS uploaded_by_name,
c.name AS category_name,
l.name AS level_name,
s.subject_name
FROM resources r
LEFT JOIN users u ON r.uploaded_by = u.id
LEFT JOIN categories c ON r.category_id = c.id
LEFT JOIN levels l ON r.level_id = l.id
LEFT JOIN subjects s ON r.subject_id = s.id
WHERE 1=1
`;
const params = [];
if (filters.category_id) {
query += ' AND r.category_id = ?';
params.push(filters.category_id);
}
if (filters.level_id) {
query += ' AND r.level_id = ?';
params.push(filters.level_id);
}
if (filters.subject_id) {
query += ' AND r.subject_id = ?';
params.push(filters.subject_id);
}
query += ' ORDER BY r.id DESC';
const [rows] = await db.query(query, params);
return rows;
};
export const getResourceById = async (id) => {
const [rows] = await db.query('SELECT * FROM resources WHERE id = ?', [id]);
return rows[0];
};
export const createResource = async (resource) => {
const sql = `
INSERT INTO resources
(title, description, google_drive_link, category_id, level_id, subject_id, uploaded_by)
VALUES (?, ?, ?, ?, ?, ?, ?)
`;
const params = [
resource.title,
resource.description,
resource.google_drive_link,
resource.category_id,
resource.level_id,
resource.subject_id,
resource.uploaded_by
];
await db.query(sql, params);
};
export const updateResource = async (id, resource) => {
const sql = `
UPDATE resources SET
title = ?, description = ?, google_drive_link = ?,
category_id = ?, level_id = ?, subject_id = ?
WHERE id = ?
`;
const params = [
resource.title,
resource.description,
resource.google_drive_link,
resource.category_id,
resource.level_id,
resource.subject_id,
id
];
await db.query(sql, params);
};
export const deleteResource = async (id) => {
await db.query('DELETE FROM resources WHERE id = ?', [id]);
};
More examples available in the official repository or by joining the support group.
MwalaJS is developed by Hekima Ambalile Mwala and the MwalaJS Team. It's open-source under the MIT License, aimed at simplifying Node.js development for beginners and experts alike.
npm update.npm audit regularly for security checks.MIT License © 2025 Hekima Mwala and MwalaJS Team. All rights reserved for contributions.
For versions below 1.0.2, download .EXE, .ZIP, or .RAR. For latest, use NPM.
Version: 1.1.0
Last Updated: December 29, 2025
MwalaJS CLI is a versatile command-line tool designed to streamline JavaScript project development. It offers features for project creation, code generation, server management, and extensive database operations supporting MySQL, PostgreSQL, SQLite, and MongoDB. This documentation provides an in-depth guide to help developers, teams, and contributors fully utilize the tool's capabilities.
The CLI is built with Node.js and ESM modules, ensuring modern, efficient performance. Whether you're a beginner setting up your first project or an advanced user managing complex database migrations, MwalaJS CLI has you covered.
MwalaJS is a lightweight, flexible CLI tool tailored for JavaScript developers. It simplifies common tasks such as creating projects, generating boilerplate code, managing servers, and handling database operations. Inspired by frameworks like Express and Laravel, MwalaJS aims to provide a seamless development experience without the overhead of heavy dependencies.
Key Features:
MwalaJS is ideal for web applications, APIs, and full-stack projects. It promotes best practices like modular code structure and secure database handling.
Tip: Always run mwala help in your terminal for a quick command reference.
To install MwalaJS CLI globally, use npm:
npm install -g mwalajs
Verify the installation:
mwala -v
Expected output: MwalaJS Version: 1.1.0
System Requirements:
If installing locally in a project:
npm install mwalajs --save-dev
Then run with npx: npx mwala help
Warning: Ensure your .env file is in the project root for database commands.
Updating MwalaJS:
npm update -g mwalajs
Check for updates regularly to get new features and bug fixes.
After installation, start by creating a new project:
mwala create-project
This sets up a basic structure with folders for models, controllers, routes, views, and middlewares.
Initialize MwalaJS in an existing project:
mwala init
Configure your database:
mwala create-db
This interactively prompts for DB type, name, host, user, and password, saving to .env.
Start the server:
mwala serve
Open http://localhost:3000 (or your configured port) to see the app running.
For a quick test, generate a model:
mwala generate model User
This creates models/User.mjs with a basic export.
mwala create-projectmwala create-dbmwala generate controller Homemwala servemwala db:table listThis workflow can be expanded for larger applications, including API development and data migrations.
These are basic commands for version and help information.
| Command | Description | Example |
|---|---|---|
mwala -v or mwala --version |
Displays the current version of MwalaJS CLI. | mwala -v → MwalaJS Version: 1.1.0 |
mwala help or mwala h |
Shows the full help menu with all available commands. | mwala help → Prints the command list |
These commands are essential for quick checks and navigation. Always refer to help when unsure about command syntax.
Commands for creating and initializing projects.
| Command | Description | Example |
|---|---|---|
mwala create-project |
Creates a new MwalaJS project with basic folder structure and files. | mwala create-project → Sets up models, controllers, etc. |
mwala init |
Initializes MwalaJS in the current directory, adding necessary config files. | mwala init → Prepares an existing folder for MwalaJS |
When creating a project, MwalaJS generates a skeleton app.mjs for entry point. Customize it as needed for your application.
mwala create-project
cd my-project
mwala init
mwala serve
This sets up and starts a basic server.
Advanced tip: Use mwala init in monorepos for multiple sub-projects.
Command to start the MwalaJS server.
| Command | Description | Example |
|---|---|---|
mwala serve |
Starts the application by spawning node app.mjs, with signal handling for clean shutdown. | mwala serve → Runs the server |
The server listens on the port specified in .env or defaults to 3000. It supports hot reloading with additional tools like nodemon (install separately).
Tip: Use nodemon -x "mwala serve" for auto-restart on file changes.
Troubleshooting: If the port is in use, change PORT in .env and restart.
Commands to generate boilerplate code for various components.
| Command | Description | Example |
|---|---|---|
mwala generate model <name> |
Creates a new model file in models/ folder. | mwala generate model User → models/User.mjs |
mwala generate controller <name> |
Creates a controller with a basic getPage method. | mwala generate controller Home → controllers/Home.mjs |
mwala generate route <name> |
Creates a route file with Router setup. | mwala generate route Api → routes/Api.mjs |
mwala generate view <name> |
Creates a basic HTML view file. | mwala generate view Index → views/Index.html |
mwala generate midware <name> |
Creates a middleware function. | mwala generate midware Auth → middlewares/Auth.mjs |
Generated files are ESM modules (.mjs) for modern JavaScript support. They include basic templates that you can extend.
mwala generate model User
mwala generate controller User
mwala generate route User
mwala generate view User
This creates a complete CRUD skeleton for 'User'.
Customization: Edit the generated files to add logic, e.g., database interactions in models.
Commands for configuring and reconfiguring the database.
| Command | Description | Example |
|---|---|---|
mwala create-db |
Interactively creates and connects to a database, saving config to .env. | mwala create-db → Prompts for DB type, name, etc. |
mwala db:config |
Reconfigures the database settings interactively. | mwala db:config → Updates .env |
Supported DB types: mysql/my, postgresql/pg, mongodb/mn, sqlite/sq. The CLI handles creation if the DB doesn't exist.
Warning: Backup .env before reconfiguring to avoid data loss.
Advanced: For custom ports, edit .env directly after initial setup.
MwalaJS provides over 20 commands for database management. All require a configured .env.
| Command | Description | Example |
|---|---|---|
mwala db:table list |
Lists all tables in the database. | mwala db:table list → Shows tables |
mwala db:table describe <name> |
Shows structure of a table (columns, types). | mwala db:table describe users → Table schema |
mwala db:table count <name> |
Counts rows in a table. | mwala db:table count users → Row count |
mwala db:table truncate <name> |
Empties a table (with confirmation). | mwala db:table truncate temp → Clears data |
mwala db:table rename <old> <new> |
Renames a table. | mwala db:table rename old_users new_users |
mwala db:table copy <src> <dest> |
Copies table structure and data. | mwala db:table copy users users_backup |
mwala db:table exists <name> |
Checks if a table exists. | mwala db:table exists users → Exists or not |
| Command | Description | Example |
|---|---|---|
mwala db:backup |
Creates a timestamped database backup. | mwala db:backup → backup-dbname-timestamp.sql |
mwala db:restore <file.sql> |
Restores from a backup file. | mwala db:restore backup.sql |
mwala db:export <table> <file.csv> |
Exports table to CSV. | mwala db:export users users.csv |
mwala db:import <file.csv> <table> |
Imports CSV into table. | mwala db:import data.csv users |
mwala db:seed <seedFile.mjs> |
Runs a seed file to populate data. | mwala db:seed seeds/initial.mjs |
| Command | Description | Example |
|---|---|---|
mwala db:size |
Shows database size. | mwala db:size → Size in MB |
mwala db:indexes <table> |
Lists indexes on a table. | mwala db:indexes users |
mwala db:vacuum |
Optimizes the database (SQLite/PostgreSQL). | mwala db:vacuum |
mwala db:connections |
Shows active connections. | mwala db:connections |
mwala db:kill-connections |
Kills other connections (with confirmation). | mwala db:kill-connections |
mwala db:drop-all-tables |
Drops all tables (dangerous, with double confirmation). | mwala db:drop-all-tables |
Database commands are cross-DB compatible where possible. For MongoDB, 'tables' are 'collections'.
mwala db:table list
mwala db:backup
mwala db:size
This lists tables, backs up, and checks size.
Security note: Use .gitignore for .env to protect credentials.
Commands for managing database schema changes.
| Command | Description | Example |
|---|---|---|
mwala migrate all |
Runs all pending migrations. | mwala migrate all → Applies changes |
mwala rollback last |
Rolls back the last migration. | mwala rollback last → Reverts last change |
Migrations are stored in migrations/ folder. Use mwala generate migration <name> to create new ones (if extended).
Warning: Always backup before migrating in production.
Extend MwalaJS by adding custom commands to the CLI script. Integrate with other tools like Docker for containerization.
Custom Environment Variables:
For CI/CD, use commands in scripts: mwala migrate all && mwala serve
Performance tip: For large databases, use batch operations in imports/exports to avoid memory issues.
Security best practices: Use environment variables for secrets, validate inputs in generated code, and use prepared statements for DB queries.
mwala create-project
mwala generate model Todo
mwala generate controller Todo
mwala generate route Todo
mwala create-db
mwala db:table create todos
mwala db:seed seeds/todos.mjs
mwala serve
This sets up a Todo API with database.
mwala db:backup
mwala db:table truncate logs
mwala db:size
mwala db:vacuum
Maintains and optimizes the DB.
More tutorials available on the MwalaJS GitHub wiki (assumed).
Common Issues:
mwala create-db to generate.For bugs, report on GitHub with logs from node --trace-warnings.
Debug mode: Add console.logs in CLI script for tracing.
Fork the repo on GitHub, make changes, submit PR. Focus on new DB features or command enhancements.
Code Standards:
Test locally with node cli.mjs help.
Contributors: Thank you for improving MwalaJS!
MwalaJS is open-source under the MIT License. Use, modify, distribute freely with attribution.
MIT License
Copyright (c) 2025 MwalaJS Team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Version: 1.1.0
Last Updated: December 29, 2025
MwalaJS CLI is a versatile command-line tool designed to streamline JavaScript project development. It offers features for project creation, code generation, server management, and extensive database operations supporting MySQL, PostgreSQL, SQLite, and MongoDB. This documentation provides an in-depth guide to help developers, teams, and contributors fully utilize the tool's capabilities.
The CLI is built with Node.js and ESM modules, ensuring modern, efficient performance. Whether you're a beginner setting up your first project or an advanced user managing complex database migrations, MwalaJS CLI has you covered.
MwalaJS is a lightweight, flexible CLI tool tailored for JavaScript developers. It simplifies common tasks such as creating projects, generating boilerplate code, managing servers, and handling database operations. Inspired by frameworks like Express and Laravel, MwalaJS aims to provide a seamless development experience without the overhead of heavy dependencies.
Key Features:
MwalaJS is ideal for web applications, APIs, and full-stack projects. It promotes best practices like modular code structure and secure database handling.
Tip: Always run mwala help in your terminal for a quick command reference.
To install MwalaJS CLI globally, use npm:
npm install -g mwalajs
Verify the installation:
mwala -v
Expected output: MwalaJS Version: 1.1.0
System Requirements:
If installing locally in a project:
npm install mwalajs --save-dev
Then run with npx: npx mwala help
Warning: Ensure your .env file is in the project root for database commands.
Updating MwalaJS:
npm update -g mwalajs
Check for updates regularly to get new features and bug fixes.
After installation, start by creating a new project:
mwala create-project
This sets up a basic structure with folders for models, controllers, routes, views, and middlewares.
Initialize MwalaJS in an existing project:
mwala init
Configure your database:
mwala create-db
This interactively prompts for DB type, name, host, user, and password, saving to .env.
Start the server:
mwala serve
Open http://localhost:3000 (or your configured port) to see the app running.
For a quick test, generate a model:
mwala generate model User
This creates models/User.mjs with a basic export.
mwala create-projectmwala create-dbmwala generate controller Homemwala servemwala db:table listThis workflow can be expanded for larger applications, including API development and data migrations.
These are basic commands for version and help information.
| Command | Description | Example |
|---|---|---|
mwala -v or mwala --version |
Displays the current version of MwalaJS CLI. | mwala -v → MwalaJS Version: 1.1.0 |
mwala help or mwala h |
Shows the full help menu with all available commands. | mwala help → Prints the command list |
These commands are essential for quick checks and navigation. Always refer to help when unsure about command syntax.
Commands for creating and initializing projects.
| Command | Description | Example |
|---|---|---|
mwala create-project |
Creates a new MwalaJS project with basic folder structure and files. | mwala create-project → Sets up models, controllers, etc. |
mwala init |
Initializes MwalaJS in the current directory, adding necessary config files. | mwala init → Prepares an existing folder for MwalaJS |
When creating a project, MwalaJS generates a skeleton app.mjs for entry point. Customize it as needed for your application.
mwala create-project
cd my-project
mwala init
mwala serve
This sets up and starts a basic server.
Advanced tip: Use mwala init in monorepos for multiple sub-projects.
Command to start the MwalaJS server.
| Command | Description | Example |
|---|---|---|
mwala serve |
Starts the application by spawning node app.mjs, with signal handling for clean shutdown. | mwala serve → Runs the server |
The server listens on the port specified in .env or defaults to 3000. It supports hot reloading with additional tools like nodemon (install separately).
Tip: Use nodemon -x "mwala serve" for auto-restart on file changes.
Troubleshooting: If the port is in use, change PORT in .env and restart.
Commands to generate boilerplate code for various components.
| Command | Description | Example |
|---|---|---|
mwala generate model <name> |
Creates a new model file in models/ folder. | mwala generate model User → models/User.mjs |
mwala generate controller <name> |
Creates a controller with a basic getPage method. | mwala generate controller Home → controllers/Home.mjs |
mwala generate route <name> |
Creates a route file with Router setup. | mwala generate route Api → routes/Api.mjs |
mwala generate view <name> |
Creates a basic HTML view file. | mwala generate view Index → views/Index.html |
mwala generate midware <name> |
Creates a middleware function. | mwala generate midware Auth → middlewares/Auth.mjs |
Generated files are ESM modules (.mjs) for modern JavaScript support. They include basic templates that you can extend.
mwala generate model User
mwala generate controller User
mwala generate route User
mwala generate view User
This creates a complete CRUD skeleton for 'User'.
Customization: Edit the generated files to add logic, e.g., database interactions in models.
Commands for configuring and reconfiguring the database.
| Command | Description | Example |
|---|---|---|
mwala create-db |
Interactively creates and connects to a database, saving config to .env. | mwala create-db → Prompts for DB type, name, etc. |
mwala db:config |
Reconfigures the database settings interactively. | mwala db:config → Updates .env |
Supported DB types: mysql/my, postgresql/pg, mongodb/mn, sqlite/sq. The CLI handles creation if the DB doesn't exist.
Warning: Backup .env before reconfiguring to avoid data loss.
Advanced: For custom ports, edit .env directly after initial setup.
MwalaJS provides over 20 commands for database management. All require a configured .env.
| Command | Description | Example |
|---|---|---|
mwala db:table list |
Lists all tables in the database. | mwala db:table list → Shows tables |
mwala db:table describe <name> |
Shows structure of a table (columns, types). | mwala db:table describe users → Table schema |
mwala db:table count <name> |
Counts rows in a table. | mwala db:table count users → Row count |
mwala db:table truncate <name> |
Empties a table (with confirmation). | mwala db:table truncate temp → Clears data |
mwala db:table rename <old> <new> |
Renames a table. | mwala db:table rename old_users new_users |
mwala db:table copy <src> <dest> |
Copies table structure and data. | mwala db:table copy users users_backup |
mwala db:table exists <name> |
Checks if a table exists. | mwala db:table exists users → Exists or not |
| Command | Description | Example |
|---|---|---|
mwala db:backup |
Creates a timestamped database backup. | mwala db:backup → backup-dbname-timestamp.sql |
mwala db:restore <file.sql> |
Restores from a backup file. | mwala db:restore backup.sql |
mwala db:export <table> <file.csv> |
Exports table to CSV. | mwala db:export users users.csv |
mwala db:import <file.csv> <table> |
Imports CSV into table. | mwala db:import data.csv users |
mwala db:seed <seedFile.mjs> |
Runs a seed file to populate data. | mwala db:seed seeds/initial.mjs |
| Command | Description | Example |
|---|---|---|
mwala db:size |
Shows database size. | mwala db:size → Size in MB |
mwala db:indexes <table> |
Lists indexes on a table. | mwala db:indexes users |
mwala db:vacuum |
Optimizes the database (SQLite/PostgreSQL). | mwala db:vacuum |
mwala db:connections |
Shows active connections. | mwala db:connections |
mwala db:kill-connections |
Kills other connections (with confirmation). | mwala db:kill-connections |
mwala db:drop-all-tables |
Drops all tables (dangerous, with double confirmation). | mwala db:drop-all-tables |
Database commands are cross-DB compatible where possible. For MongoDB, 'tables' are 'collections'.
mwala db:table list
mwala db:backup
mwala db:size
This lists tables, backs up, and checks size.
Security note: Use .gitignore for .env to protect credentials.
Commands for managing database schema changes.
| Command | Description | Example |
|---|---|---|
mwala migrate all |
Runs all pending migrations. | mwala migrate all → Applies changes |
mwala rollback last |
Rolls back the last migration. | mwala rollback last → Reverts last change |
Migrations are stored in migrations/ folder. Use mwala generate migration <name> to create new ones (if extended).
Warning: Always backup before migrating in production.
Extend MwalaJS by adding custom commands to the CLI script. Integrate with other tools like Docker for containerization.
Custom Environment Variables:
For CI/CD, use commands in scripts: mwala migrate all && mwala serve
Performance tip: For large databases, use batch operations in imports/exports to avoid memory issues.
Security best practices: Use environment variables for secrets, validate inputs in generated code, and use prepared statements for DB queries.
mwala create-project
mwala generate model Todo
mwala generate controller Todo
mwala generate route Todo
mwala create-db
mwala db:table create todos
mwala db:seed seeds/todos.mjs
mwala serve
This sets up a Todo API with database.
mwala db:backup
mwala db:table truncate logs
mwala db:size
mwala db:vacuum
Maintains and optimizes the DB.
More tutorials available on the MwalaJS GitHub wiki (assumed).
Common Issues:
mwala create-db to generate.For bugs, report on GitHub with logs from node --trace-warnings.
Debug mode: Add console.logs in CLI script for tracing.
Fork the repo on GitHub, make changes, submit PR. Focus on new DB features or command enhancements.
Code Standards:
Test locally with node cli.mjs help.
Contributors: Thank you for improving MwalaJS!
MwalaJS is open-source under the MIT License. Use, modify, distribute freely with attribution.
MIT License
Copyright (c) 2025 MwalaJS Team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Get real-time help from the community and developers.
Click here to join