Last active
June 2, 2020 15:32
-
-
Save Raduuu/d74b509855c9e8c174b468605f8f7c90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mongoose from 'mongoose' | |
const productSchema = new mongoose.Schema( | |
{ | |
name: { | |
type: String, | |
required: true, | |
trim: true, | |
maxlength: 50, | |
text: true | |
}, | |
description: { | |
type: String, | |
required: true, | |
trim: true, | |
maxlength: 100 | |
}, | |
quantity: { | |
type: Number, | |
required: true, | |
trim: true, | |
maxlength: 3 | |
}, | |
price: { | |
type: Number, | |
required: true, | |
trim: true, | |
maxlength: 3 | |
}, | |
}, | |
{ timestamps: true } | |
) | |
productSchema.index({ category: 1, name: 1 }, { unique: true }) | |
export const Product = mongoose.model('product', productSchema) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment