{"size": 1114, "ext": "js", "max_stars_repo_path": "src/models/news.model.js", "max_stars_repo_name": "Tien194264/Boilerplate", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/models/news.model.js", "max_issues_repo_name": "Tien194264/Boilerplate", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/models/news.model.js", "max_forks_repo_name": "Tien194264/Boilerplate", "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": 17.1384615385, "max_line_length": 50, "alphanum_fraction": 0.4901256732}
const mongoose = require('mongoose');
const { toJSON, paginate } = require('./plugins');
const { roles } = require('../config/roles');


const newsSchema = mongoose.Schema({
   
    title: {
        type: 'String',
        required: true,
        trim: true,
        uppercase: true,
        minLengthen: 10,
        maxLengthen: 100,
    },
    created: {
        type: 'Date',
        required: true,
    },
    author: {
        type: 'String',
        required: true,
        trim: true,
        uppercase: true,
    },
    category: {
        type: 'String',
        required: true,
    },
    content: {
        type: 'String',
        required: true,
        trim: true,
        minLengthen: 100,

    },
    image: {
        type: 'String',
        trim: true,
    },
    comments: {
        type: 'String',
        trim: true,

    },
    role: {
        type: String,
        enum: roles,
        default: 'user',
      },
},
    
    {
        timestamps: true,
    }
);

newsSchema.plugin(toJSON);
newsSchema.plugin(paginate);



const News = mongoose.model('News', newsSchema);

module.exports = News;