api/resources/Products/ProductModel.js
Sibunnayak cf993bf06a update
2024-07-26 08:39:02 +05:30

66 lines
1.4 KiB
JavaScript

import mongoose from "mongoose";
const { Schema, model } = mongoose;
const productSchema = new Schema(
{
name: {
type: String,
maxLength: [35, "name cannot exceed 25 characters"],
required: [true, "Please Enter product Name"],
trim: true,
},
category: {
type: Schema.Types.ObjectId,
ref: "CategoryModel",
},
price: {
type: Number,
required: true,
},
GST: {
type: mongoose.Schema.ObjectId,
ref: "Tax",
},
description: {
type: String,
maxLength: [400, "description cannot exceed 100 characters"],
required: [true, "Please Enter product Description"],
},
special_instructions: {
type: String,
},
featured_Product: {
type: Boolean,
default: false, // Initially, products are not featured
},
image: [
{
public_id: {
type: String,
// required: true,
},
url: {
type: String,
// required: true,
},
},
],
product_Status: {
type: String,
enum: ["Active", "inActive"],
default: "Active",
},
addedBy: {
type: Schema.Types.ObjectId,
required: true,
ref: "User",
},
},
{ timestamps: true }
);
export const Product = model("Product", productSchema);