clark-orm
TypeScript icon, indicating that this package has built-in type declarations

3.5.3 • Public • Published

npm version

ClarkORM

If you like this project, please give us a star on Github.

ClarkORM is a Typescript ORM built on top of Lucid ORM (AdonisJS).

Why

AdonisJS is a great framework and it has one of the best ORM. But it works only in its ecosystem. Using ClarkORM you can have all the benefits of Lucid, but in any Node.js project you want.

How it works

ClarkORM is built on top of Lucid ORM and Lucid ORM is built on top of knex. The idea of ClarkORM is let you manage your migrations and seeds with knex the way you already do. But when it comes to Models ClarkORM comes on scene.

Installation

npm install clark-orm
npm install luxon

Usage

Here you can configure your connection like Adonis Lucid

// database.ts
import { defineConfig } from "clark-orm";

export const { BaseModel, Event, Database } = defineConfig({
  connection: "sqlite",
  connections: {
    sqlite: {
      client: "sqlite",
      healthCheck: false,
      debug: false,
      useNullAsDefault: true,
      connection: {
        filename: "./db.sqlite",
      },
    },
  },
})
// models/city.ts
import { DateTime } from "luxon";
import { column } from "clark-orm";
import { BaseModel } from "../database";

export class CityModel extends BaseModel {
  public static table = "cities";

  @column({ isPrimary: true })
  public id: number;

  @column()
  public name: string;

  @column.dateTime({ autoCreate: true })
  public createdAt: DateTime;

  @column.dateTime({ autoCreate: true, autoUpdate: true })
  public updatedAt: DateTime;
}

You can learn more about the models here.

Extra

To use ClarkORM you need to know at least a little about knex and Lucid

Do you like to learn with examples? We have one here

Package Sidebar

Install

npm i clark-orm

Weekly Downloads

6

Version

3.5.3

License

MIT

Unpacked Size

9.45 kB

Total Files

6

Last publish

Collaborators

  • gideaoms