Skip to content

Instantly share code, notes, and snippets.

@unicodeveloper
Created August 18, 2017 02:54
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 unicodeveloper/3ae2cacadfb2c78b2fa77accab0dbd8f to your computer and use it in GitHub Desktop.
Save unicodeveloper/3ae2cacadfb2c78b2fa77accab0dbd8f to your computer and use it in GitHub Desktop.
// Define our Note model
module.exports = (Sequelize, DataTypes, UserModel) => {
 return Sequelize.define(‘notes’, {
 id: {
  type: DataTypes.INTEGER,
  primaryKey: true,
  allowNull: false,
  autoIncrement: true,
 },
 title: {
  type: DataTypes.TEXT,
  allowNull: false,
 },
 body: {
  type: DataTypes.TEXT,
  allowNull: false,
 },
 userId: {
  type: DataTypes.INTEGER,
  allowNull: false,
  references: {
  model: UserModel,
  key: ‘id’,
 },
 },
 createdAt: {
  type: DataTypes.DATE,
  defaultValue: DataTypes.NOW,
  allowNull: false,
 },
 updatedAt: {
  type: DataTypes.DATE,
  defaultValue: DataTypes.NOW,
  allowNull: false,
 },
 });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment