@tabletennisshop/common 1.0.36 → 1.0.38
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.
@@ -4,7 +4,7 @@ exports.InventoryModel = void 0;
|
|
4
4
|
const mongoose_1 = require("mongoose");
|
5
5
|
// Define the schema for the inventory model
|
6
6
|
const InventorySchema = new mongoose_1.Schema({
|
7
|
-
product_id: { type:
|
7
|
+
product_id: { type: mongoose_1.Schema.Types.ObjectId, required: true, ref: 'Product' }, // Reference to the Product model
|
8
8
|
total_quantity: { type: Number, required: true, default: 0 }, // Total quantity of the product
|
9
9
|
serials: { type: [String], required: false }, // Optional array of serial numbers
|
10
10
|
}, {
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { Document, Model, Types } from "mongoose";
|
2
|
+
export interface IRatingAttrs {
|
3
|
+
user_id: Types.ObjectId;
|
4
|
+
product_id: Types.ObjectId;
|
5
|
+
comment?: string;
|
6
|
+
rate_score: number;
|
7
|
+
}
|
8
|
+
interface RatingDoc extends IRatingAttrs, Document {
|
9
|
+
createdAt: Date;
|
10
|
+
updatedAt: Date;
|
11
|
+
}
|
12
|
+
export interface RatingModel extends Model<RatingDoc> {
|
13
|
+
build(attrs: IRatingAttrs): RatingDoc;
|
14
|
+
}
|
15
|
+
export declare const RatingModel: RatingModel;
|
16
|
+
export {};
|
@@ -0,0 +1,50 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
36
|
+
exports.RatingModel = void 0;
|
37
|
+
const mongoose_1 = __importStar(require("mongoose"));
|
38
|
+
const RatingSchema = new mongoose_1.Schema({
|
39
|
+
user_id: { type: mongoose_1.Schema.Types.ObjectId, required: true, ref: 'User' },
|
40
|
+
product_id: { type: mongoose_1.Schema.Types.ObjectId, required: true, ref: 'Product' },
|
41
|
+
comment: { type: String, required: false },
|
42
|
+
rate_score: { type: Number, required: true }
|
43
|
+
}, {
|
44
|
+
timestamps: true,
|
45
|
+
collection: 'rating'
|
46
|
+
});
|
47
|
+
RatingSchema.statics.build = (attrs) => {
|
48
|
+
return new exports.RatingModel(attrs);
|
49
|
+
};
|
50
|
+
exports.RatingModel = mongoose_1.default.model('Rating', RatingSchema);
|