Skip to content

Instantly share code, notes, and snippets.

@david-mart
Last active June 11, 2019 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save david-mart/af3c8e8f48ba0c768f73879c0370eaa7 to your computer and use it in GitHub Desktop.
Save david-mart/af3c8e8f48ba0c768f73879c0370eaa7 to your computer and use it in GitHub Desktop.
// models/user.js
module.exports = (sequelize, DataTypes) =>
sequelize.define(
"user",
{
id: {
type: DataTypes.INTEGER(11),
allowNull: false,
primaryKey: true,
autoIncrement: true
},
name: {
type: DataTypes.STRING(255),
allowNull: true
}
},
{
tableName: "user",
timestamps: false
}
);
// models/order.js
module.exports = (sequelize, DataTypes) =>
sequelize.define(
"order",
{
id: {
type: DataTypes.INTEGER(11),
allowNull: false,
primaryKey: true,
autoIncrement: true
},
user_id: {
type: DataTypes.INTEGER(11),
allowNull: false
},
order_date: {
type: DataTypes.DATE,
allowNull: true
}
},
{
tableName: "order",
timestamps: false
}
);
// models/product.js
module.exports = (sequelize, DataTypes) =>
sequelize.define(
"product",
{
id: {
type: DataTypes.INTEGER(11),
allowNull: false,
primaryKey: true,
autoIncrement: true
},
order_id: {
type: DataTypes.INTEGER(11),
allowNull: false
},
name: {
type: DataTypes.STRING(255),
allowNull: true
}
},
{
tableName: "product",
timestamps: false
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment