Untitled

mail@pastecode.io avatar
unknown
plain_text
15 days ago
1.7 kB
2
Indexable
Never
const mongoose = require('mongoose');

const productSchema = new mongoose.Schema({
    sku: {
        type: String,
        unique: true,
        required: true
    },
    quantity: {
        type: Number,
        min: 0, required: true
    },
    name: {
        type: Map,
        of: String,
        required: true
    },
    description: {
        type: Map,
        of: String, required: true
    },
    images:
        [{
            type: mongoose.Schema.Types.ObjectId,
            ref: 'Image'
        }],
    offer:
    {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Offer'
    },
    categories:
        [{
            type: mongoose.Schema.Types.ObjectId,
            ref: 'Category'
        }],
    subcategories:
        [{
            type: mongoose.Schema.Types.ObjectId,
            ref: 'SubCategory'
    }],
    groups:
        [{ type: mongoose.Schema.Types.ObjectId, ref: 'Group' }],
    brand:
        { type: mongoose.Schema.Types.ObjectId, ref: 'Brand' },
    tags:
        [String],
    pricing: {
        initialPrice: {
            type: Number,
            min: 0, required: true
        },
        listPrice: {
            type: Number, min: 0,
            required: true
        },
        publicPrice: {
            type: Number,
            min: 0, required: true
        },
        discountPrices: [{
            type: Number,
            min: 0
        }]
    },
    visibility: {
        type: Boolean,
        required: true
    },
    // stockStatus: { type: Boolean, default: true }

});

const Product = mongoose.model('Product', productSchema);

module.exports = Product;
Leave a Comment