sequelize-automate
Version:
Automatically generate bare sequelize models from your database.
13 lines (12 loc) • 1.98 kB
JSON
[
{
"file": "user.ts",
"code": "import { Sequelize, DataTypes } from 'sequelize';\nexport default function (sequelize: Sequelize) {\n const attributes = {\n id: {\n type: DataTypes.INTEGER(11).UNSIGNED,\n allowNull: false,\n defaultValue: null,\n primaryKey: true,\n autoIncrement: true,\n comment: \"primary ket\",\n field: \"id\"\n },\n name: {\n type: DataTypes.STRING(100),\n allowNull: false,\n defaultValue: null,\n primaryKey: false,\n autoIncrement: false,\n comment: \"user name\",\n field: \"name\",\n unique: \"uk_name\"\n },\n email: {\n type: DataTypes.STRING(255),\n allowNull: false,\n defaultValue: null,\n primaryKey: false,\n autoIncrement: false,\n comment: \"user email\",\n field: \"email\"\n },\n created_at: {\n type: DataTypes.DATE,\n allowNull: false,\n defaultValue: null,\n primaryKey: false,\n autoIncrement: false,\n comment: \"created datetime\",\n field: \"created_at\"\n },\n updated_at: {\n type: DataTypes.DATE,\n allowNull: false,\n defaultValue: null,\n primaryKey: false,\n autoIncrement: false,\n comment: \"updated datetime\",\n field: \"updated_at\"\n }\n };\n const options = {\n tableName: \"user\",\n comment: \"\",\n indexes: []\n };\n const UserModel = sequelize.define(\"user_model\", attributes, options);\n return UserModel;\n}",
"fileType": "model"
},
{
"file": "user.d.ts",
"code": "import { Model, BuildOptions } from 'sequelize';\nexport interface IUserAttributes {\n id: number,\n name: string,\n email: string,\n created_at: Date,\n updated_at: Date,\n}\nexport interface IUserModel extends IUserAttributes, Model {}\nexport type IUserModelStatic = typeof Model & {\n new (values?: object, options?: BuildOptions): IUserModel;\n};",
"fileType": "definition"
}
]