1.0.25 • Published 5 years ago

sequelize-formly v1.0.25

Weekly downloads
26
License
MIT
Repository
-
Last release
5 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

5 years ago

1.0.24

8 years ago

1.0.23

8 years ago

1.0.22

8 years ago

1.0.21

9 years ago

1.0.20

9 years ago

1.0.19

10 years ago

1.0.18

10 years ago

1.0.17

10 years ago

1.0.16

10 years ago

1.0.15

10 years ago

1.0.14

10 years ago

1.0.13

10 years ago

1.0.12

10 years ago

1.0.11

10 years ago

1.0.10

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.0

10 years ago