/***
 *
 * @description This model represent the gym products collection schema in mongodb
 * * source : https://mongoosejs.com/docs/guide.html
 */
import mongoose, { Model } from 'mongoose';
import { IProductsSchema } from '@/types/IDB';
// define the schema
const productsSchema = new mongoose.Schema<IProductsSchema>({
    name: String,
    description: String,
    price: Number,
    quantity: Number,
}, { timestamps: true });
// export the model
// Clear any existing model to avoid schema conflicts
if (mongoose.models.products) {
    delete mongoose.models.products;
}

const productsModel: Model<IProductsSchema> = mongoose.model<IProductsSchema>('products', productsSchema);
export default productsModel