api/resources/Products/ProductModel.js
2024-04-05 17:40:41 +05:30

68 lines
1.5 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"],
},
price: {
type: Number,
required: [true, "Please Enter product Price"],
maxLength: [8, "Price can not exceed 8 characters"],
},
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,
},
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,
ref: "User",
},
},
{ timestamps: true }
);
export const Product = model("Product", productSchema);