convert schema objects to model with nodejs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
Convert Schema to Model in Nestjs
|
|
|
|
|
|
|
|
|
|
``` sh
|
|
|
|
|
node index.js
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
just copy schema to ##schema.txt like this:
|
|
|
|
|
``` js
|
|
|
|
|
{
|
|
|
|
|
// category: 'اطلاعات هویتی'
|
|
|
|
|
username: {
|
|
|
|
|
type: this.DataTypes.STRING(50),
|
|
|
|
|
allowNull: true,
|
|
|
|
|
desc: "نام کاربری",
|
|
|
|
|
category: "اطلاعات هویتی",
|
|
|
|
|
regex: "[^a-zA-Z0-9@_./-]+",
|
|
|
|
|
},
|
|
|
|
|
password: {
|
|
|
|
|
type: this.DataTypes.TEXT,
|
|
|
|
|
allowNull: true,
|
|
|
|
|
desc: "کلمهی عبور",
|
|
|
|
|
},
|
|
|
|
|
firstName: {
|
|
|
|
|
type: this.DataTypes.STRING,
|
|
|
|
|
allowNull: true,
|
|
|
|
|
desc: "نام",
|
|
|
|
|
category: "اطلاعات هویتی",
|
|
|
|
|
regex: "[^ آابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهیئ]+",
|
|
|
|
|
readOnly: true,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
and when index.js is executed, result will be:
|
|
|
|
|
``` js
|
|
|
|
|
@Column({
|
|
|
|
|
type:DataType.STRING,
|
|
|
|
|
allowNull:true,
|
|
|
|
|
desc:"نام کاربری",
|
|
|
|
|
category:"اطلاعات هویتی",
|
|
|
|
|
regex:"[^a-zA-Z0-9@_./-]+",
|
|
|
|
|
validate:{is:/[^a-zA-Z0-9@_./-]+}/},
|
|
|
|
|
})
|
|
|
|
|
username:string;
|
|
|
|
|
|
|
|
|
|
@Column({
|
|
|
|
|
type:DataType.TEXT,
|
|
|
|
|
allowNull:true,
|
|
|
|
|
desc:"کلمهی عبور",
|
|
|
|
|
})
|
|
|
|
|
password:string;
|
|
|
|
|
|
|
|
|
|
@Column({
|
|
|
|
|
type:DataType.STRING,
|
|
|
|
|
allowNull:true,
|
|
|
|
|
desc:"نام",
|
|
|
|
|
category:"اطلاعات هویتی",
|
|
|
|
|
regex:"[^ آابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهیئ]+",
|
|
|
|
|
validate:{is:/[^ آابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهیئ]+}/},
|
|
|
|
|
readOnly:true,
|
|
|
|
|
})
|
|
|
|
|
firstName:string;
|
|
|
|
|
```
|