@tabletennisshop/common 1.0.24 → 1.0.26

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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AddressSchema = void 0;
4
+ //This is subdocument schema
4
5
  const mongoose_1 = require("mongoose");
5
6
  exports.AddressSchema = new mongoose_1.Schema({
6
7
  province: { type: String, required: true },
@@ -46,9 +46,12 @@ exports.ProductModel = void 0;
46
46
  // src/models/product.model.ts
47
47
  const mongoose_1 = __importStar(require("mongoose"));
48
48
  //We don't need "interface ProductModel extends Model<>" for this
49
+ // because we don't have any static methods or custom instance methods
50
+ // like "build" or "findById" in this model.
51
+ // Define the base options for the schema
49
52
  const baseOptions = {
50
- discriminatorKey: 'type',
51
- collection: 'product',
53
+ discriminatorKey: 'type', // This is used to differentiate between different types of products
54
+ collection: 'product', // The name of the collection in MongoDB
52
55
  timestamps: true
53
56
  };
54
57
  const ProductSchema = new mongoose_1.Schema({
@@ -2,11 +2,11 @@ import { Document, Model } from "mongoose";
2
2
  import { IAddress } from "./address.schema";
3
3
  export interface VendorAttrs {
4
4
  name: string;
5
- address: IAddress;
5
+ addresses: IAddress[];
6
6
  }
7
7
  interface VendorDoc extends Document {
8
8
  name: string;
9
- address: IAddress;
9
+ addresses: IAddress[];
10
10
  }
11
11
  interface VendorModel extends Model<VendorDoc> {
12
12
  build(attr: VendorAttrs): VendorDoc;
@@ -5,7 +5,9 @@ const mongoose_1 = require("mongoose");
5
5
  const address_schema_1 = require("./address.schema");
6
6
  const VendorSchema = new mongoose_1.Schema({
7
7
  name: { type: String, required: true },
8
- address: { type: address_schema_1.AddressSchema, required: true }
8
+ addresses: [
9
+ { type: address_schema_1.AddressSchema, required: true }
10
+ ]
9
11
  }, {
10
12
  timestamps: true,
11
13
  collection: "vendor"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tabletennisshop/common",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",