Installation
Install Hysteria ORM using your preferred package manager:
yarn add hysteria-orm
# or
npm install --save hysteria-orm
Development dependencies
- When working with typescript in a development environment, you need to install the following dependencies
- Those allow you to run the hysteria binary in development mode and to interact with typescript files
yarn add bundle-require esbuild -D
Peer Dependencies
- Make sure you have the correct database driver installed for your target database:
- PostgreSQL:
pg - MySQL/MariaDB:
mysql2 - SQLite:
sqlite3 - MongoDB:
mongodb - Redis:
ioredis
- PostgreSQL:
Example:
npm install pg mysql2 sqlite3 mongodb ioredis
Quick Setup with CLI
Hysteria ORM provides a CLI tool to quickly initialize your project with the standard configuration. This will create the necessary folder structure and configuration files. It also installs the necessary dependencies for the database you choose (alongside the dev dependencies for the project).
Initialize with CLI
npx hysteria init --type <database-type>
Available Database Types
postgres- PostgreSQLmysql- MySQLmariadb- MariaDBsqlite- SQLitecockroachdb- CockroachDBmongodb- MongoDBredis- Redis
Example Usage
# Initialize with PostgreSQL
npx hysteria init --type postgres
# Initialize with MySQL
npx hysteria init --type mysql
# Initialize with SQLite
npx hysteria init --type sqlite
What the CLI Creates
The init command will create the following structure:
your-project/
├── database/
│ ├── index.ts # Database connection configuration
│ └── migrations/ # Migration files folder only if the connection is a sql database
The generated database/index.ts file will contain the proper connection configuration for your chosen database type.
Next: Setup