Skip to main content

MongoDB Introduction

Hysteria ORM provides experimental support for MongoDB, allowing you to define collections, perform CRUD operations, and use a fluent query builder with a similar API to SQL models.

Key Features

  • Decorator-based collection definition
  • Type-safe queries and models
  • Query builder with chaining and filtering
  • Session and transaction support (with replica sets)
  • Automatic mapping of id to MongoDB _id

Note: MongoDB support is experimental. Some features may be missing or unstable.

Example Usage

import { mongo } from 'hysteria-orm';
await mongo.connect('mongodb://root:root@localhost:27017');

import { User } from './collections/User';
const users = await User.find();

Next: Defining Collections