1.0.25 • Published 4 years ago

sequelize-formly v1.0.25

Weekly downloads
26
License
MIT
Repository
-
Last release
4 years ago

sequelize-formly

A module that produces a REST options for a database schema in a formly format. NOTE: Currently, this implementation supports POSTGRESQL only.

Prerequisites

This module requires:

express
sequelize

Installation

$ npm install sequelize-formly

Usage

To define the route, do:

var sequelizeFormly = require('sequelize-formly');
app.options('/hammers', sequelizeFormly.formly(Model));

or

import sequelizeFormly from "sequelize-formly";
app.options('/hammers', sequelizeFormly.formly(Model));

API

A correct execution returns a 201 status code.

app.options('/hammers', sequelizeFormly.formly(Model));

Example request:

OPTIONS /hammers
Content-Type: application/json
{
    "key": "hammers",
    "type": "input",
    "templateOptions": {
      "type": "number",
      "label": "hammers",
      "required": true
    }
}

LABEL FORMLY IN SEQUELIZE

xlabel needs to be defined in each model field.

Field1: {
    type: DataType.BLOB,
    field: 'demo1',
    allowNull: false,
    xlabel: "Demo Label 1",
}

CHOICE FORMLY IN SEQUELIZE

xchoice needs to be added to belongsto relations in the model.

Model1.belongsTo(Model2, {as: 'model_relation', foreignKey:{name: 'id_model', allowNull: false, xchoice:'field_name'}});

or by concatenating fields

Model1.belongsTo(Model2, {as: 'model_relation', foreignKey:{name: 'id_model', allowNull: false, xchoice:'field_name1+field_name2'}});

ADD CORS

var cors = require('cors');
app.use(cors({
        "origin": "*",
        "methods": "GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS",
        "preflightContinue": true,
        "headers": "Content-Type, Authorization, Content-Length, X-Requested-With",
        "Access-Control-Allow-Headers": "Authorization, Content-Type"
    }));
1.0.25

4 years ago

1.0.24

6 years ago

1.0.23

7 years ago

1.0.22

7 years ago

1.0.21

8 years ago

1.0.20

8 years ago

1.0.19

8 years ago

1.0.18

8 years ago

1.0.17

8 years ago

1.0.16

8 years ago

1.0.15

8 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.0

8 years ago