Untitled

mail@pastecode.io avatar
unknown
plain_text
17 days ago
781 B
1
Indexable
Never
const mongoose = require('mongoose');

const OfferSchema = new mongoose.Schema(
  {
    name: {
        type: String,
        unique:true,
        required: [true, 'content is require!'],
    },
    discount : {
        type : Number,
        required: [true, 'discount is require!'],
        max: 100,
        min: 0,
        validate : {
            validator : Number.isInteger,
            message   : '{VALUE} is not an integer value'
          }
    },
    status: {
        type: Boolean,
        required: [true, 'status is require!'],
        default: true
    },
  },
  {
    timestamps: true // Ajoute automatiquement les champs createdAt et updatedAt
  }
);

const Offer = mongoose.model('Offer', OfferSchema);

module.exports = Offer;
Leave a Comment