Skip to content

Devmojos/node-db-model-helper

Repository files navigation

db-model-helper

Introduction

Db Model helper is a helper to get model and other information from an existent database.

Database Support

For now, the only database supported is Mysql

Install

npm i @devmojos/db-model-helper --save

Usage Example

import DbHelpers from '@devmojos/db-model-helper';
import { IDBHelper, IDBAttribute } from '@devmojos/db-model-helper/common/types';

const mysqlHelper : IDBHelper = DbHelpers.mysql({
    host: "localhost",
    user: "username",
    password: "password",
    database: "database_name",
    port: 3306
});

const displayInfo = async (db: IDBHelper) => {

    //create a pool to the database
    mysqlHelper.createPool();

    //
    // Run how many queries you want
    //

    //Tables
    const tables : string[] = await db.model.getTables();
    console.log("Tables: ", tables )

    //Columns
    const columns = await db.model.getColumns("some_table");
    console.log("Columns: ", columns);

    //
    //Close database connection when you don't need it anymore
    //
    db.close();

};

displayInfo(mysqlHelper);

Development

install

npm install

build

npm run build

test

npm test

run locally

#You need to create your own index.development.ts first
npm run local

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published