@chevre/domain 21.9.0-alpha.2 → 21.9.0-alpha.3
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.
|
@@ -9,19 +9,19 @@ mongoose.Model.on('index', (...args) => {
|
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex:
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const catalogItemRepo = new chevre.repository.OfferCatalogItem(mongoose.connection);
|
|
15
15
|
|
|
16
16
|
console.log('searching...');
|
|
17
|
-
const catalogs = await
|
|
17
|
+
const catalogs = await catalogItemRepo.search(
|
|
18
18
|
{
|
|
19
19
|
project: { id: { $eq: PROJECT_ID } },
|
|
20
|
-
identifier: { $eq: '0001' },
|
|
21
20
|
sort: { identifier: chevre.factory.sortType.Descending },
|
|
22
21
|
limit: 2,
|
|
23
22
|
page: 1,
|
|
24
23
|
itemListElement: { typeOf: { $eq: 'Offer' } }
|
|
24
|
+
// id: { $in: ['xxx'] }
|
|
25
25
|
}
|
|
26
26
|
);
|
|
27
27
|
console.log('catalogs found', catalogs.map((catalog) => `${catalog.identifier} ${catalog.numberOfItems} ${catalog.itemListElementTypeOf}`));
|
|
@@ -2,7 +2,7 @@ import { Connection } from 'mongoose';
|
|
|
2
2
|
import * as factory from '../factory';
|
|
3
3
|
export type IAggregatedOfferCatalog = Pick<factory.offerCatalog.IOfferCatalog, 'id' | 'name' | 'description' | 'project' | 'typeOf' | 'identifier' | 'itemOffered' | 'additionalProperty'> & {
|
|
4
4
|
numberOfItems?: number;
|
|
5
|
-
itemListElementTypeOf:
|
|
5
|
+
itemListElementTypeOf: factory.offerType.Offer;
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
8
|
* オファーカタログアイテムリポジトリ
|
|
@@ -21,6 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.MongoRepository = void 0;
|
|
24
|
+
const mongoose_1 = require("mongoose");
|
|
24
25
|
const factory = require("../factory");
|
|
25
26
|
const offerCatalogItem_1 = require("./mongoose/schemas/offerCatalogItem");
|
|
26
27
|
/**
|
|
@@ -32,7 +33,7 @@ class MongoRepository {
|
|
|
32
33
|
}
|
|
33
34
|
// tslint:disable-next-line:max-func-body-length
|
|
34
35
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
35
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
36
37
|
// MongoDB検索条件
|
|
37
38
|
const andConditions = [];
|
|
38
39
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
@@ -41,19 +42,17 @@ class MongoRepository {
|
|
|
41
42
|
}
|
|
42
43
|
const idIn = (_c = params.id) === null || _c === void 0 ? void 0 : _c.$in;
|
|
43
44
|
if (Array.isArray(idIn)) {
|
|
44
|
-
andConditions.push({ _id: { $in: idIn } });
|
|
45
|
+
andConditions.push({ _id: { $in: idIn.map((id) => new mongoose_1.Types.ObjectId(id)) } });
|
|
45
46
|
}
|
|
46
|
-
const idRegex =
|
|
47
|
-
if (typeof idRegex === 'string' && idRegex.length > 0) {
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
const identifierEq = (
|
|
47
|
+
// const idRegex = params.id?.$regex;
|
|
48
|
+
// if (typeof idRegex === 'string' && idRegex.length > 0) {
|
|
49
|
+
// andConditions.push({ _id: { $regex: new RegExp(idRegex) } });
|
|
50
|
+
// }
|
|
51
|
+
const identifierEq = (_d = params.identifier) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
51
52
|
if (typeof identifierEq === 'string') {
|
|
52
|
-
andConditions.push({
|
|
53
|
-
identifier: { $eq: identifierEq }
|
|
54
|
-
});
|
|
53
|
+
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
55
54
|
}
|
|
56
|
-
const identifierRegex = (
|
|
55
|
+
const identifierRegex = (_e = params.identifier) === null || _e === void 0 ? void 0 : _e.$regex;
|
|
57
56
|
if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
|
|
58
57
|
andConditions.push({ identifier: { $regex: new RegExp(identifierRegex) } });
|
|
59
58
|
}
|
|
@@ -65,31 +64,31 @@ class MongoRepository {
|
|
|
65
64
|
]
|
|
66
65
|
});
|
|
67
66
|
}
|
|
68
|
-
const itemListElementTypeOfEq = (
|
|
67
|
+
const itemListElementTypeOfEq = (_g = (_f = params.itemListElement) === null || _f === void 0 ? void 0 : _f.typeOf) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
69
68
|
if (typeof itemListElementTypeOfEq === 'string') {
|
|
70
69
|
andConditions.push({ 'itemListElement.typeOf': { $exists: true, $eq: itemListElementTypeOfEq } });
|
|
71
70
|
}
|
|
72
|
-
const itemListElementIdIn = (
|
|
71
|
+
const itemListElementIdIn = (_j = (_h = params.itemListElement) === null || _h === void 0 ? void 0 : _h.id) === null || _j === void 0 ? void 0 : _j.$in;
|
|
73
72
|
if (Array.isArray(itemListElementIdIn)) {
|
|
74
73
|
andConditions.push({ 'itemListElement.id': { $exists: true, $in: itemListElementIdIn } });
|
|
75
74
|
}
|
|
76
|
-
const itemListElementIdNin = (
|
|
75
|
+
const itemListElementIdNin = (_l = (_k = params.itemListElement) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$nin;
|
|
77
76
|
if (Array.isArray(itemListElementIdNin)) {
|
|
78
77
|
andConditions.push({ 'itemListElement.id': { $nin: itemListElementIdNin } });
|
|
79
78
|
}
|
|
80
|
-
const itemListElementIdAll = (
|
|
79
|
+
const itemListElementIdAll = (_o = (_m = params.itemListElement) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$all;
|
|
81
80
|
if (Array.isArray(itemListElementIdAll)) {
|
|
82
81
|
andConditions.push({ 'itemListElement.id': { $exists: true, $all: itemListElementIdAll } });
|
|
83
82
|
}
|
|
84
|
-
const itemOfferedTypeOfEq = (
|
|
83
|
+
const itemOfferedTypeOfEq = (_q = (_p = params.itemOffered) === null || _p === void 0 ? void 0 : _p.typeOf) === null || _q === void 0 ? void 0 : _q.$eq;
|
|
85
84
|
if (typeof itemOfferedTypeOfEq === 'string') {
|
|
86
85
|
andConditions.push({ 'itemOffered.typeOf': { $exists: true, $eq: itemOfferedTypeOfEq } });
|
|
87
86
|
}
|
|
88
|
-
const itemOfferedServiceTypeCodeValueEq = (
|
|
87
|
+
const itemOfferedServiceTypeCodeValueEq = (_t = (_s = (_r = params.itemOffered) === null || _r === void 0 ? void 0 : _r.serviceType) === null || _s === void 0 ? void 0 : _s.codeValue) === null || _t === void 0 ? void 0 : _t.$eq;
|
|
89
88
|
if (typeof itemOfferedServiceTypeCodeValueEq === 'string') {
|
|
90
89
|
andConditions.push({ 'itemOffered.serviceType.codeValue': { $exists: true, $eq: itemOfferedServiceTypeCodeValueEq } });
|
|
91
90
|
}
|
|
92
|
-
const additionalPropertyElemMatch = (
|
|
91
|
+
const additionalPropertyElemMatch = (_u = params.additionalProperty) === null || _u === void 0 ? void 0 : _u.$elemMatch;
|
|
93
92
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
94
93
|
andConditions.push({ additionalProperty: { $exists: true, $elemMatch: additionalPropertyElemMatch } });
|
|
95
94
|
}
|
package/package.json
CHANGED