{"size": 1033, "ext": "js", "max_stars_repo_path": "server/app/model/models/BoardItem.js", "max_stars_repo_name": "pavelsvagr/taskboard", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/app/model/models/BoardItem.js", "max_issues_repo_name": "pavelsvagr/taskboard", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/app/model/models/BoardItem.js", "max_forks_repo_name": "pavelsvagr/taskboard", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.4905660377, "max_line_length": 52, "alphanum_fraction": 0.6563407551}
const mongoose = require("mongoose")
const BoardModel = require("./Board")
const MemberModel = require("./Member")
const { AssignmentSchema } = require("./Assignment")

const BoardItem = require("../entities/BoardItem")


const SCHEMA = "board_items"
const ATTR_MEMBER = "member"
const ATTR_BOARD = "board"
const ATTR_DATE = "date"
const ATTR_ASSIGNMENTS = "assignments"

const { Schema } = mongoose

const BoardItemSchema = new Schema(
  {
    [ATTR_MEMBER]: {
      type: Schema.Types.ObjectID,
      required: true,
      ref: MemberModel.SCHEMA
    },
    [ATTR_BOARD]: {
      type: Schema.Types.ObjectID,
      required: true,
      ref: BoardModel.SCHEMA
    },
    [ATTR_DATE]: {
      type: Date,
      required: true
    },
    [ATTR_ASSIGNMENTS]: [
      {
        type: AssignmentSchema
      }
    ]
  },
  { timestamps: true }
)

BoardItemSchema.loadClass(BoardItem)
mongoose.model(SCHEMA, BoardItemSchema)

module.exports = {
  BoardItemSchema,
  SCHEMA,
  ATTR_MEMBER,
  ATTR_BOARD,
  ATTR_DATE,
  ATTR_ASSIGNMENTS
}
