sequelize-to-json-schema
Sequelize model generate to json schema.
get started
-
install
npm install sequelize-model-to-json-schema --save
how to use
-
transform
-
demo
const s2json =const Project = sequelizeconst transformModel = s2json<!--type: 'object'properties:id: type: 'integer' format: 'int32' description: undefinedtitle: type: 'string' maxLength: 255 description: 'title'bigint: type: 'integer' format: 'int32' description: 'test bigint'number: type: 'number' format: 'double' description: 'test double'number_decimal: type: 'number' description: 'test decimal'uuid: type: 'string' format: 'uuid' description: 'test uuid'description: type: 'string' description: 'description'createdAt:type: 'string' format: 'date-time' description: undefinedupdatedAt:type: 'string' format: 'date-time' description: undefined--> -
exclude
const s2json =const Project = sequelizeconst transformModel = s2json<!--type: 'object'properties:id: type: 'integer' format: 'int32' description: undefineddescription: type: 'string' description: 'description'createdAt:type: 'string' format: 'date-time' description: undefinedupdatedAt:type: 'string' format: 'date-time' description: undefined-->
-
-
convert
-
string
const convertStr =test:type: SequelizeSTRINGcomment: 'test field'const convertJson = s2json<!--type: 'object'properties:test: type: 'string' description: 'test field'--> -
object
const convertObj =test:type: Sequelizekeys:test:type: SequelizeSTRINGcomment: 'test field'const convertJson = s2json<!--type: 'object'properties:test:type: 'object'properties:test: type: 'string' description: 'test field'--> -
array
const convertArr =test:type: Sequelizeitems:test:type: SequelizeSTRINGcomment: 'test field'const convertJson = s2json<!--type: 'object'properties:test:type: 'array'items:type: 'object'properties:test: type: 'string' description: 'test field'-->
-