{"size": 1055, "ext": "js", "max_stars_repo_path": "server/models/borrowrequests.js", "max_stars_repo_name": "amarachukwu-agbo/hello-books", "max_stars_repo_stars_event_min_datetime": "2018-03-30T12:45:31.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-08T22:56:05.000Z", "max_issues_repo_path": "server/models/borrowrequests.js", "max_issues_repo_name": "amarachukwu-agbo/hello-books", "max_issues_repo_issues_event_min_datetime": "2017-10-13T20:26:16.000Z", "max_issues_repo_issues_event_max_datetime": "2018-07-16T16:00:47.000Z", "max_forks_repo_path": "server/models/borrowrequests.js", "max_forks_repo_name": "amarachukwu-agbo/hello-books", "max_forks_repo_forks_event_min_datetime": "2018-09-29T18:15:24.000Z", "max_forks_repo_forks_event_max_datetime": "2018-10-06T01:01:02.000Z"}
{"max_stars_count": 2, "max_issues_count": 51, "max_forks_count": 2, "avg_line_length": 22.9347826087, "max_line_length": 61, "alphanum_fraction": 0.6018957346}
import * as Sequelize from 'sequelize';

const borrowRequestSchema = (sequelize) => {
  const BorrowRequests = sequelize.define('BorrowRequests', {
    id: {
      allowNull: false,
      autoIncrement: true,
      primaryKey: true,
      type: Sequelize.INTEGER,
    },
    reason: {
      type: Sequelize.ENUM,
      values: ['Research', 'Assignment', 'Leisure reading'],
      allowNull: false,
    },
    comments: {
      type: Sequelize.TEXT,
      allowNull: true,
    },
    returnDate: {
      type: Sequelize.DATE,
      allowNull: false,
    },
    status: {
      type: Sequelize.STRING,
      defaultValue: 'Pending',
      allowNull: false,
    },
  });
  BorrowRequests.associate = (models) => {
    BorrowRequests.belongsTo(models.User, {
      foreignKey: 'userId',
      as: 'userBorrowRequests',
      onDelete: 'CASCADE',
    });
    BorrowRequests.belongsTo(models.Book, {
      foreignKey: 'bookId',
      as: 'borrowRequests',
      onDelete: 'CASCADE',
    });
  };
  return BorrowRequests;
};

export default borrowRequestSchema;
