@dynamatix/gb-schemas 0.13.1 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
|
|
3
|
+
// Define Variant Schema
|
|
4
|
+
const VariantSchema = new mongoose.Schema({
|
|
5
|
+
id: { type: String, required: true },
|
|
6
|
+
name: { type: String, required: true },
|
|
7
|
+
variantCode: { type: String, required: true }
|
|
8
|
+
}, {
|
|
9
|
+
_id: false // Prevents automatic `_id` creation for array elements
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
// Define Product Variant Schema
|
|
13
|
+
const ProductVariantSchema = new mongoose.Schema({
|
|
14
|
+
variants: { type: [VariantSchema], default: [] } // Array of variants
|
|
15
|
+
}, {
|
|
16
|
+
timestamps: true
|
|
17
|
+
});
|
|
18
|
+
const ProductVariantModel = mongoose.model("ProductVariant", ProductVariantSchema);
|
|
19
|
+
module.exports = ProductVariantModel;
|