0.2.0 • Published 9 months ago

@achtjs/sql v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@achtjs/sql

Installation

  • Install AchtJS Sql plugin
npm i @achtjs/sql
  • Install Sequelize. AchtJS uses sequelize as an ORM.
npm install --save sequelize

You'll also have to manually install the driver for your database of choice:

# One of the following:
$ npm install --save pg pg-hstore # Postgres
$ npm install --save mysql2
$ npm install --save mariadb
$ npm install --save sqlite3

Sql

This will creates a MySql Database that will be consume on AppModule class. It accepts an object of settings for mysql connection. This database will be consume by Mayajs in compilation and automatically connects the database when the start function is called.

Import

import { SqlModule } from "@achtjs/sql";

Implementation

const options = {
    name: "main",
    options: {
        database: "achtjs",
        username: "achtjs",
        password: "achtjs123",
        options: {
            host: "127.0.0.1",
            dialect: "mysql",
        },
    },
    schemas: [sample],
};

SqlModule.forRoot(options);

Adding Sql on App Decorator

import { Module } from "@achtjs/core";

const options = {...}

@Module({
    declarations: [...],
    imports: [SqlModule.forRoot(options)],
    providers: ...,
    bootstrap: ...,
})
export class AppModule {}

Examples

Check out live examples for more info.

0.2.0

9 months ago

0.1.3

9 months ago

0.1.2

9 months ago

1.0.0

9 months ago