Getting Started

NexORM is a powerful ORM designed to simplify database management while delivering high performance and flexibility. Inspired by MongoDB, Prisma, and TypeORM, it combines the best features of these tools, offering advanced operators (like $set and $inc with more), a built-in caching system, and a decorator-based schema definition for clean and intuitive modeling.
With full TypeScript support, Nexorm ensures type-safe , modern development using JavaScript (ES2021). It supports MySQL, PostgreSQL, SQLite, MariaDB, and MSSQL, making it suitable for projects of any scale, from small apps to complex enterprise systems.
Start building with NexORM to enjoy effortless, scalable, and maintainable database interactions.
Features
Full Type Support: Seamless TypeScript integration for type-safe development.
Decorator-Based Schema Definition: Clean and intuitive schema modeling using decorators.
Multi-Database Support: Compatible with MySQL, PostgreSQL, SQLite, MariaDB, and MSSQL.
Full JSON Support: Easily handle arrays and objects in JSON format.
Hooks Support: Lifecycle hooks for enhanced control over database events.
Encryption, Decryption, and Hashing: Built-in utilities for secure data management.
Validation Support: Ensure data integrity with powerful validation tools.
Multi-Connection Support: Manage multiple database connections effortlessly.
CLI Support: Command-line tools for streamlined database operations.
Cache Support: Built-in caching for faster queries and improved performance.
Index Support: Optimize queries with advanced indexing capabilities.
Advanced Operator Support: Extendable operators for flexible database operations.
Debug and Logging Support: Track and troubleshoot with detailed logs and debug tools.
And more...
With NexORM your schemas & models look like this:
And your domain logic will look this way:
Installation
Install the npm package:
npm install nexorm --saveYou may need to install
reflect-metadata:npm install reflect-metadata --saveand import it somewhere in the global place of your app (for example insrc/index.ts):import 'reflect-metadata';You may need to install node typings:
npm install @types/node --save-devInstall a database driver:
for MySQL
npm install mysql2 --savefor PostgreSQL
npm install pg --savefor SQLite
npm install sqlite3 --savefor Microsoft SQL Server
npm install tedious --savefor MariaDB
npm install mariadb --save
TypeScript Configuration
Also, make sure you are using TypeScript version 4.5 or higher, and you have enabled the following settings in tsconfig.json:
You may also need to enable es6 in the lib section of compiler options, or install es6-shim from @types.
Quick Start
The quickest way to get started with NexORM is to use its CLI commands to generate a nexorm.config.ts or file.nexorm.config.js
After edit the nexorm.config.ts or file and put your own database connection configuration options in there:nexorm.config.js
Configuration File Options
You can adjust the configuration file according to your needs using the table below.
$provider*
'nexorm' | String
nexorm
$database*
'mysql' | 'postgres' | 'sqlite' | 'mariadb' | 'mssql'
sqlite
$dialectModule?
any
(Empty)
$autoConnect?
Boolean
true
$filePath?
String
./nexorm.sqlite
$databaseEngine?
String
B-tree
$ssl?
Boolean
(Empty)
$pool?
Object
(Empty)
$pool.$acquire?
Number
(Empty)
$pool.$idle?
Number
(Empty)
$pool.$max?
Number
(Empty)
$pool.$min?
Number
(Empty)
$pool.$evict?
Number
(Empty)
$onConnection?
Function
(() ⇒ {..});
$onDisconnect?
Function
(Empty)
$onError?
Function
(() ⇒ {..});
$host?
String
(Empty)
$port?
String
(Empty)
$username?
String
(Empty)
$password?
String
(Empty)
$connectionURI?
String
(Empty)
$cache?
Object
(Empty)
$cache.$type?
'memory'
(Empty)
$cache.$duration?
Number
(Empty)
Create Model
Working with a database starts with creating tables. How do you tell NexORM to create a database table? The answer is - through the models. Your models in your app are your database tables.
For example, you have a Member model:
And you want to store photos in your database. To store things in the database, first, you need a database table, and database tables are created from your models. Not all models, but only those you define as entities.
Updating in the database
Now let's update a member from the database:
Searching in the database
Now let's search a member from the database:
Deleting in the database
Now let's delete a member from the database:
Last updated
