Warp Server ORM

6.8.7 · active · verified Sun Apr 19

Warp Server is an Object-Relational Mapper (ORM) designed for scalable web applications, currently at version 6.8.7. It provides a structured approach to defining database schemas, including tables, columns with validation, and triggers for pre- and post-operation hooks. Developers can build complex queries, implement server-side functions for custom business logic, and enforce access restrictions based on user roles. A key differentiator is its built-in support for implementing RESTful APIs via an Express middleware. As of now, it exclusively supports MySQL, with the roadmap indicating plans for additional database adapters in future releases. The project maintains a stable release cadence, with version 6.x being the current focus, explicitly differentiating its documentation and usage from older versions 5.x and legacy releases.

Common errors

Warnings

Install

Imports

Quickstart

Initializes a Warp service instance with a MySQL database connection, demonstrating the basic setup and asynchronous initialization.

import 'reflect-metadata';
import Warp from 'warp-server';

// Replace with your actual database connection string
const databaseURI = 'mysql://youruser:password@yourserver.com:3306/yourdatabase?charset=utf8';

const service = new Warp({ databaseURI });

async function startService() {
  try {
    await service.initialize();
    console.log('Warp service initialized successfully. You can now define and interact with your models.');
    // Example: You would define your classes and start querying here.
    // @Class()
    // class User {
    //   @Key({ primary: true, autoIncrement: true }) id: number;
    //   @Key() name: string;
    // }
    // service.define(User);
    // const newUser = await service.create(User, { name: 'John Doe' });
    // console.log('New user created:', newUser);
  } catch (error) {
    console.error('Failed to initialize Warp service:', error);
  }
}

startService();

view raw JSON →