82 lines
1.9 KiB
JavaScript
82 lines
1.9 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,
|
|
},
|
|
// uniqueId: {
|
|
// type: String,
|
|
// required: true,
|
|
// },
|
|
description: {
|
|
type: String,
|
|
maxLength: [400, "description cannot exceed 100 characters"],
|
|
required: [true, "Please Enter product Description"],
|
|
},
|
|
|
|
category: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: "CategoryModel",
|
|
},
|
|
// gst: {
|
|
// type: Schema.Types.ObjectId,
|
|
// ref: "Tax",
|
|
// },
|
|
// total_amount: {
|
|
// type: Number,
|
|
// required: true,
|
|
// },
|
|
// gst_amount: {
|
|
// type: Number,
|
|
// required: true,
|
|
// },
|
|
special_instructions: {
|
|
type: String,
|
|
},
|
|
variants: [
|
|
{
|
|
variant_Name: { type: String, default: "" },
|
|
weight: { type: Number, default: 0 },
|
|
volume: { type: Number, default: 0 },
|
|
price: { type: String, default: "" },
|
|
// gst_Name: { type: String, default: "" },
|
|
// gst_Rate: { type: String, default: "" },
|
|
gst_Id: {
|
|
type: mongoose.Schema.ObjectId,
|
|
ref: "Tax",
|
|
},
|
|
},
|
|
],
|
|
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);
|