Skip to content

A library created with the concept of facilitating the creation of api.

License

Notifications You must be signed in to change notification settings

ivanantunes/zmodule-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A library created with the concept of facilitating the creation of api.

npm version npm downloads

Develop Doc's

Base Structure

.
├── FolderMyProject
|   ├── src
|   |   ├── locale
|   |   |   ├── translate.ts
|   |   └── 
|   |   ├── index.ts
|   |   ├── .env
|   └── 
└──

QuickStart

# Database configuration

# Supported: mysql | mariadb | postgres | mssql / Default Value: mysql 
DB_DIALECT=
# Default Value: localhost
DB_HOST=
# Default Value: zmodule_api
DB_NAME=
# Default Value: 3306
DB_PORT=
# Default Value: root
DB_USER=
# Default Value: 
DB_PASSWORD=

# Module Configuration

# Default Value: pt 
MOD_LANG=
# Default Value: ../../../../src/locale/translate
MOD_LANG_PATH=
# Default Value: 3000
MOD_SERVER_PORT=

# Mail Configuration

# Default Value:
MAIL_HOST=
# Default Value:
MAIL_PORT=
# Default Value:
MAIL_USER=
# Default Value:
MAIL_PASSWORD=
# Default Value:
MAIL_SECURE=
# Default Value:
MAIL_SERVICE=
# Default Value:
MAIL_TLS_REJECT=
import { zEFieldTypeDB, zITableDB, zCrudService, zDatabaseService } from 'zmodule-api';
import { switchMap } from 'rxjs/operators';

const zTableTest: zITableDB = {
    tableName: 'zTableTest',
    tableFields: [
        {
            fieldName: 'zTest_ID',
            fieldPrimaryKey: true,
            fieldRequired: true,
            fieldType: zEFieldTypeDB.BIGINT,
            fieldAutoIncrement: true
        },
        {
            fieldName: 'zTest_NAME',
            fieldPrimaryKey: false,
            fieldRequired: true,
            fieldType: zEFieldTypeDB.VARCHAR,
            fieldSize: 100
        },
        {
            fieldName: 'zTest_LAST_NAME',
            fieldPrimaryKey: false,
            fieldRequired: true,
            fieldType: zEFieldTypeDB.VARCHAR,
            fieldSize: 100
        },
        {
            fieldName: 'zTest_EMAIL',
            fieldPrimaryKey: false,
            fieldRequired: true,
            fieldType: zEFieldTypeDB.VARCHAR,
            fieldSize: 100,
            fieldValidate: {
                isEmail: true
            }
        },
        {
            fieldName: 'zTest_OBS',
            fieldPrimaryKey: false,
            fieldRequired: false,
            fieldAllowNull: true,
            fieldType: zEFieldTypeDB.TEXT,
            fieldTextLength: 'medium',
        },
    ]
};

zDatabaseService.getInstance().createTable(zTableTest).pipe(
    switchMap(() => {
        const obj = {
                zTest_NAME: 'Name',
                zTest_LAST_NAME: 'Lastname',
                zTest_EMAIL: 'zmodule_api@email.com',
                zTest_OBS: 'My Obs...',
            };

        return zCrudService.getInstance().create(obj, 'zTableTest');
    }),
).subscribe((response) => {
    console.log(response);
}, (err) => {
    console.log(err);
});

About

A library created with the concept of facilitating the creation of api.

Resources

License

Stars

Watchers

Forks

Packages

No packages published