JS20

Documentation

JS20 - Documentation

Database Migration

Initialize tables automatically

const database = new MySqlDatabase(connectOptions, {
    initializeTables: true,
});

Provides the following output:

✓ MySQL connected

> SQL Query:
CREATE TABLE IF NOT EXISTS `Cars` (
  `isLeased` TINYINT(1) NOT NULL,
  `registrationNumber` VARCHAR(255) NOT NULL,
  `id` CHAR(36) BINARY NOT NULL,
  `createdAt` DATETIME NOT NULL,
  `updatedAt` DATETIME NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_bin;

Express server is running on port 3000 🚀

What's happening here?

  • By setting initializeTables: true JS20 automatically issues create queries for all models
  • The table columns are derived from models & their schemas
JS20