| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- var Schema = require('mongoose').Schema;
- const commentSchema = new Schema({
- page: {
- type: String,
- required: true,
- trim: true,
- maxlength: 100,
- },
- name: {
- type: String,
- required: true,
- trim: true,
- maxlength: 100
- },
- email: {
- type: String,
- required: true,
- trim: true,
- lowercase: true,
- validate: {
- validator: function (v) {
- return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v);
- },
- message: props => `${props.value} is not a valid email address!`
- }
- },
- comment: {
- type: String,
- required: true,
- trim: true,
- maxlength: 1000
- },
- createdAt: {
- type: Date,
- default: Date.now
- },
- approved: {
- type: Boolean,
- default: false
- }
- });
- module.exports = commentSchema;
|