Giter Site home page Giter Site logo

clark-orm's Introduction

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 @adonisjs/lucid 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",
      debug: false,
      useNullAsDefault: true,
      connection: {
        filename: "./db.sqlite",
      },
    },
  },
})
// models/city.ts
import { DateTime } from "luxon";
import { column } from "@adonisjs/lucid/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

Remember to add it to your tsconfig.json

"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false

clark-orm's People

Contributors

gideaoms avatar jeanbispo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

clark-orm's Issues

Bot for autoupdate

A good idea is to configure a bot to automatically open PR's as soon as there is an update from lucid, as soon as I have time I will try to develop this idea.

Congratulations on the project haha, I was in a huge effort doing everything manually here as knex and I found this mention of the project: adonisjs/lucid#695 (comment)

Incomplete connection Config

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/clark-orm/web-app.js b/node_modules/clark-orm/web-app.js
index 228753d..cd8d027 100644
--- a/node_modules/clark-orm/web-app.js
+++ b/node_modules/clark-orm/web-app.js
@@ -29,6 +29,7 @@ webApp.container.singleton('Adonis/Core/Config', () => {
                 user: knexfile.connection.user,
                 password: knexfile.connection.password,
                 database: knexfile.connection.database,
+                ssl: knexfile.connection.ssl,
             },
         };
     return new config_1.Config({

This issue body was partially generated by patch-package.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.