@chevre/domain 21.18.0-alpha.32 → 21.18.0-alpha.34
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/example/src/chevre/upsertMoviesByIdentifier.ts +5 -4
- package/example/src/chevre/upsertOfferCatalogsByIdentifier.ts +19 -16
- package/example/src/chevre/upsertScreeningEventSeriesByVersion.ts +7 -44
- package/lib/chevre/repo/creativeWork.d.ts +7 -1
- package/lib/chevre/repo/creativeWork.js +30 -15
- package/lib/chevre/repo/event.d.ts +5 -2
- package/lib/chevre/repo/event.js +29 -24
- package/lib/chevre/repo/offerCatalog.d.ts +9 -3
- package/lib/chevre/repo/offerCatalog.js +17 -60
- package/lib/chevre/service/event.js +1 -1
- package/package.json +1 -1
|
@@ -14,9 +14,9 @@ async function main() {
|
|
|
14
14
|
const result = await creativeWorkRepo.upsertMoviesByIdentifier(
|
|
15
15
|
[
|
|
16
16
|
{
|
|
17
|
-
|
|
17
|
+
$set: {
|
|
18
18
|
id: '',
|
|
19
|
-
identifier: '
|
|
19
|
+
identifier: '20231215',
|
|
20
20
|
typeOf: chevre.factory.creativeWorkType.Movie,
|
|
21
21
|
duration: 'PT2H',
|
|
22
22
|
name: { ja: '名探偵コナン ゼロの執行人', en: 'Detective Conan Zero Enforcer' },
|
|
@@ -34,7 +34,7 @@ async function main() {
|
|
|
34
34
|
value: 'https://iwiz-movies.c.yimg.jp/c/movies/pict/p/p/90/cb/174755_02.jpg'
|
|
35
35
|
}
|
|
36
36
|
],
|
|
37
|
-
headline: '
|
|
37
|
+
// headline: 'サブタイトルサブタイトル',
|
|
38
38
|
datePublished: moment('2018-11-04T15:00:00.000Z')
|
|
39
39
|
.toDate(),
|
|
40
40
|
distributor: {
|
|
@@ -44,7 +44,8 @@ async function main() {
|
|
|
44
44
|
distributorType: '001'
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
},
|
|
48
|
+
$unset: { headline: 1 }
|
|
48
49
|
}
|
|
49
50
|
],
|
|
50
51
|
{ replace: true }
|
|
@@ -14,23 +14,26 @@ async function main() {
|
|
|
14
14
|
const result = await offerCatalogRepo.upsertManyByIdentifier(
|
|
15
15
|
[
|
|
16
16
|
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
$set: {
|
|
18
|
+
project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
|
|
19
|
+
typeOf: 'OfferCatalog',
|
|
20
|
+
id: '',
|
|
21
|
+
identifier: '2023121501',
|
|
22
|
+
itemListElement: [
|
|
23
|
+
{ id: '1001', typeOf: chevre.factory.offerType.Offer }
|
|
24
|
+
],
|
|
25
|
+
itemOffered: { typeOf: chevre.factory.product.ProductType.EventService },
|
|
26
|
+
name: {
|
|
27
|
+
en: '2023121501',
|
|
28
|
+
ja: '2023121501'
|
|
29
|
+
},
|
|
30
|
+
description: {
|
|
31
|
+
en: '2023121501',
|
|
32
|
+
ja: '2023121501'
|
|
33
|
+
},
|
|
34
|
+
additionalProperty: []
|
|
28
35
|
},
|
|
29
|
-
|
|
30
|
-
en: '2023121301',
|
|
31
|
-
ja: '2023121301'
|
|
32
|
-
},
|
|
33
|
-
additionalProperty: []
|
|
36
|
+
$unset: {}
|
|
34
37
|
}
|
|
35
38
|
]
|
|
36
39
|
// { replace: true }
|
|
@@ -15,7 +15,7 @@ async function main() {
|
|
|
15
15
|
const result = await eventRepo.upsertScreeningEventSeriesByVersion(
|
|
16
16
|
[
|
|
17
17
|
{
|
|
18
|
-
|
|
18
|
+
$set: {
|
|
19
19
|
eventStatus: chevre.factory.eventStatusType.EventScheduled,
|
|
20
20
|
videoFormat: [],
|
|
21
21
|
soundFormat: [],
|
|
@@ -50,50 +50,13 @@ async function main() {
|
|
|
50
50
|
duration: 'PT1H29M',
|
|
51
51
|
version: '2'
|
|
52
52
|
},
|
|
53
|
-
organizer: { id: '59d20831e53ebc2b4e774466' }
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
attributes: {
|
|
58
|
-
eventStatus: chevre.factory.eventStatusType.EventScheduled,
|
|
59
|
-
videoFormat: [],
|
|
60
|
-
soundFormat: [],
|
|
61
|
-
kanaName: '',
|
|
62
|
-
startDate: moment('2023-12-08T15:00:00Z')
|
|
63
|
-
.toDate(),
|
|
64
|
-
endDate: moment('2123-12-08T15:00:00Z')
|
|
65
|
-
.toDate(),
|
|
66
|
-
typeOf: chevre.factory.eventType.ScreeningEventSeries,
|
|
67
|
-
duration: 'PT2H',
|
|
68
|
-
name: { ja: '名探偵コナン ゼロの執行人', en: 'Detective Conan Zero Enforcer' },
|
|
69
|
-
offers: {
|
|
70
|
-
typeOf: chevre.factory.offerType.Offer
|
|
71
|
-
},
|
|
72
|
-
project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
|
|
73
|
-
additionalProperty: [
|
|
74
|
-
],
|
|
75
|
-
location: {
|
|
76
|
-
branchCode: '118',
|
|
77
|
-
id: '5bfb841d5a78d7948369979a',
|
|
78
|
-
kanaName: 'シネモーションアカサカ',
|
|
79
|
-
name: { ja: 'シネモーション赤坂 ', en: 'CineMotion Akasaka' },
|
|
80
|
-
typeOf: chevre.factory.placeType.MovieTheater
|
|
81
|
-
},
|
|
82
|
-
workPerformed: {
|
|
83
|
-
typeOf: chevre.factory.creativeWorkType.Movie,
|
|
84
|
-
id: '5bfb841d5a78d79483699801',
|
|
85
|
-
identifier: '071953',
|
|
86
|
-
name: {
|
|
87
|
-
ja: '男はつらいよ 純情篇'
|
|
88
|
-
},
|
|
89
|
-
duration: 'PT1H29M',
|
|
90
|
-
version: '3'
|
|
91
|
-
},
|
|
92
|
-
organizer: { id: '59d20831e53ebc2b4e774466' }
|
|
93
|
-
}
|
|
53
|
+
organizer: { id: '59d20831e53ebc2b4e774466' },
|
|
54
|
+
headline: { ja: 'xxx', en: '' }
|
|
55
|
+
},
|
|
56
|
+
$unset: {}
|
|
94
57
|
},
|
|
95
58
|
{
|
|
96
|
-
|
|
59
|
+
$set: {
|
|
97
60
|
eventStatus: chevre.factory.eventStatusType.EventScheduled,
|
|
98
61
|
videoFormat: [],
|
|
99
62
|
soundFormat: [],
|
|
@@ -126,7 +89,7 @@ async function main() {
|
|
|
126
89
|
ja: '男はつらいよ 純情篇'
|
|
127
90
|
},
|
|
128
91
|
duration: 'PT1H29M',
|
|
129
|
-
version: '
|
|
92
|
+
version: '6'
|
|
130
93
|
},
|
|
131
94
|
organizer: { id: '59d20831e53ebc2b4e774466' }
|
|
132
95
|
}
|
|
@@ -37,6 +37,9 @@ export declare class MongoRepository {
|
|
|
37
37
|
* コンテンツを保管する
|
|
38
38
|
*/
|
|
39
39
|
saveMovie(params: factory.creativeWork.movie.ICreativeWork & {
|
|
40
|
+
/**
|
|
41
|
+
* ドキュメント作成時には無視される
|
|
42
|
+
*/
|
|
40
43
|
$unset?: {
|
|
41
44
|
[key in keyof factory.creativeWork.movie.ICreativeWork]?: 1;
|
|
42
45
|
};
|
|
@@ -45,7 +48,10 @@ export declare class MongoRepository {
|
|
|
45
48
|
* コードをキーにして冪等作成
|
|
46
49
|
*/
|
|
47
50
|
upsertMoviesByIdentifier(params: {
|
|
48
|
-
|
|
51
|
+
$set: factory.creativeWork.movie.ICreativeWork;
|
|
52
|
+
$unset?: {
|
|
53
|
+
[key in keyof factory.creativeWork.movie.ICreativeWork]?: 1;
|
|
54
|
+
};
|
|
49
55
|
}[], options?: {
|
|
50
56
|
replace?: boolean;
|
|
51
57
|
}): Promise<{
|
|
@@ -121,12 +121,13 @@ class MongoRepository {
|
|
|
121
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
122
|
let doc;
|
|
123
123
|
if (params.id === '') {
|
|
124
|
-
|
|
124
|
+
const { $unset } = params, createParams = __rest(params, ["$unset"]);
|
|
125
|
+
doc = yield this.creativeWorkModel.create(createParams);
|
|
125
126
|
}
|
|
126
127
|
else {
|
|
127
|
-
// 上書き禁止属性を除外
|
|
128
|
-
const { id, identifier, project, typeOf } = params,
|
|
129
|
-
doc = yield this.creativeWorkModel.findOneAndUpdate({ _id: { $eq: params.id } },
|
|
128
|
+
// 上書き禁止属性を除外
|
|
129
|
+
const { id, identifier, project, typeOf, $unset } = params, setFields = __rest(params, ["id", "identifier", "project", "typeOf", "$unset"]);
|
|
130
|
+
doc = yield this.creativeWorkModel.findOneAndUpdate({ _id: { $eq: params.id } }, Object.assign({ $set: setFields }, ($unset !== undefined) ? { $unset } : undefined), { upsert: false, new: true })
|
|
130
131
|
.exec();
|
|
131
132
|
}
|
|
132
133
|
if (doc === null) {
|
|
@@ -143,28 +144,42 @@ class MongoRepository {
|
|
|
143
144
|
return __awaiter(this, void 0, void 0, function* () {
|
|
144
145
|
const bulkWriteOps = [];
|
|
145
146
|
if (Array.isArray(params)) {
|
|
146
|
-
|
|
147
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
148
|
+
params.forEach(({ $set, $unset }) => {
|
|
147
149
|
// リソースのユニークネスを保証するfilter
|
|
148
150
|
const filter = {
|
|
149
|
-
typeOf:
|
|
150
|
-
'project.id': { $eq:
|
|
151
|
-
identifier: { $eq:
|
|
151
|
+
typeOf: $set.typeOf,
|
|
152
|
+
'project.id': { $eq: $set.project.id },
|
|
153
|
+
identifier: { $eq: $set.identifier }
|
|
152
154
|
};
|
|
153
155
|
if ((options === null || options === void 0 ? void 0 : options.replace) === true) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
// updateOneで再実装
|
|
157
|
+
// const replacement: WithoutId<factory.creativeWork.movie.ICreativeWork> = replaceFields;
|
|
158
|
+
// const replaceOne: ReplaceOneModel<factory.creativeWork.movie.ICreativeWork> = {
|
|
159
|
+
// filter,
|
|
160
|
+
// replacement,
|
|
161
|
+
// upsert: true
|
|
162
|
+
// };
|
|
163
|
+
// bulkWriteOps.push({ replaceOne });
|
|
164
|
+
const { id, identifier, project, typeOf } = $set, setFields = __rest($set, ["id", "identifier", "project", "typeOf"]);
|
|
165
|
+
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
156
166
|
throw new factory.errors.ArgumentNull('identifier');
|
|
157
167
|
}
|
|
158
|
-
const
|
|
159
|
-
|
|
168
|
+
const setOnInsert = {
|
|
169
|
+
typeOf,
|
|
170
|
+
project,
|
|
171
|
+
identifier
|
|
172
|
+
};
|
|
173
|
+
const updateFilter = Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
|
|
174
|
+
const updateOne = {
|
|
160
175
|
filter,
|
|
161
|
-
|
|
176
|
+
update: updateFilter,
|
|
162
177
|
upsert: true
|
|
163
178
|
};
|
|
164
|
-
bulkWriteOps.push({
|
|
179
|
+
bulkWriteOps.push({ updateOne });
|
|
165
180
|
}
|
|
166
181
|
else {
|
|
167
|
-
const { typeOf, project, identifier, duration, name, additionalProperty, contentRating, headline, distributor, thumbnailUrl, datePublished } =
|
|
182
|
+
const { typeOf, project, identifier, duration, name, additionalProperty, contentRating, headline, distributor, thumbnailUrl, datePublished } = $set, setOnInsertFields = __rest($set, ["typeOf", "project", "identifier", "duration", "name", "additionalProperty", "contentRating", "headline", "distributor", "thumbnailUrl", "datePublished"]);
|
|
168
183
|
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
169
184
|
throw new factory.errors.ArgumentNull('identifier');
|
|
170
185
|
}
|
|
@@ -123,10 +123,10 @@ export declare class MongoRepository {
|
|
|
123
123
|
* コンテンツ+バージョンをキーにして冪等置換
|
|
124
124
|
*/
|
|
125
125
|
upsertScreeningEventSeriesByVersion(params: {
|
|
126
|
-
|
|
126
|
+
$set: factory.event.IAttributes<factory.eventType.ScreeningEventSeries>;
|
|
127
|
+
$unset?: IUnset<factory.eventType.ScreeningEventSeries>;
|
|
127
128
|
}[]): Promise<{
|
|
128
129
|
bulkWriteResult4insert: BulkWriteResult;
|
|
129
|
-
bulkWriteResult: BulkWriteResult;
|
|
130
130
|
modifiedEvents: {
|
|
131
131
|
id: string;
|
|
132
132
|
}[];
|
|
@@ -147,6 +147,9 @@ export declare class MongoRepository {
|
|
|
147
147
|
save<T extends factory.eventType>(params: {
|
|
148
148
|
id?: string;
|
|
149
149
|
attributes: factory.event.IAttributes<T>;
|
|
150
|
+
/**
|
|
151
|
+
* ドキュメント作成時には無視される
|
|
152
|
+
*/
|
|
150
153
|
$unset?: IUnset<T>;
|
|
151
154
|
upsert?: boolean;
|
|
152
155
|
}): Promise<factory.event.IEvent<T>>;
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -615,54 +615,59 @@ class MongoRepository {
|
|
|
615
615
|
) {
|
|
616
616
|
return __awaiter(this, void 0, void 0, function* () {
|
|
617
617
|
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
618
|
-
// replaceOneでは_idを指定できないので、updateOne(setOnInsert)->replaceOneの2段階でbulkWriteを実行する
|
|
619
618
|
const bulkWriteOps4insert = [];
|
|
620
|
-
const bulkWriteOps = [];
|
|
619
|
+
// const bulkWriteOps: AnyBulkWriteOperation<factory.event.IAttributes<factory.eventType.ScreeningEventSeries>>[] = [];
|
|
621
620
|
const queryFilters = [];
|
|
622
621
|
if (Array.isArray(params)) {
|
|
623
|
-
params.forEach(({
|
|
624
|
-
const version =
|
|
622
|
+
params.forEach(({ $set, $unset }) => {
|
|
623
|
+
const version = $set.workPerformed.version;
|
|
625
624
|
if (typeof version !== 'string' || version.length === 0) {
|
|
626
625
|
throw new factory.errors.ArgumentNull('workPerformed.version');
|
|
627
626
|
}
|
|
628
627
|
// リソースのユニークネスを保証するfilter
|
|
629
628
|
const filter = {
|
|
630
|
-
typeOf:
|
|
631
|
-
'project.id': { $eq:
|
|
632
|
-
'location.branchCode': { $exists: true, $eq:
|
|
633
|
-
'workPerformed.identifier': { $exists: true, $eq:
|
|
629
|
+
typeOf: $set.typeOf,
|
|
630
|
+
'project.id': { $eq: $set.project.id },
|
|
631
|
+
'location.branchCode': { $exists: true, $eq: $set.location.branchCode },
|
|
632
|
+
'workPerformed.identifier': { $exists: true, $eq: $set.workPerformed.identifier },
|
|
634
633
|
'workPerformed.version': { $exists: true, $eq: version }
|
|
635
634
|
};
|
|
636
635
|
queryFilters.push({
|
|
637
|
-
typeOf:
|
|
638
|
-
'project.id': { $eq:
|
|
639
|
-
'location.branchCode': { $exists: true, $eq:
|
|
640
|
-
'workPerformed.identifier': { $exists: true, $eq:
|
|
636
|
+
typeOf: $set.typeOf,
|
|
637
|
+
'project.id': { $eq: $set.project.id },
|
|
638
|
+
'location.branchCode': { $exists: true, $eq: $set.location.branchCode },
|
|
639
|
+
'workPerformed.identifier': { $exists: true, $eq: $set.workPerformed.identifier },
|
|
641
640
|
'workPerformed.version': { $exists: true, $eq: version }
|
|
642
641
|
});
|
|
643
|
-
const
|
|
642
|
+
const { identifier, project, typeOf } = $set, setFields = __rest($set, ["identifier", "project", "typeOf"]);
|
|
643
|
+
const setOnInsert = {
|
|
644
|
+
project,
|
|
645
|
+
typeOf,
|
|
646
|
+
_id: uniqid()
|
|
647
|
+
};
|
|
644
648
|
const updateOne = {
|
|
645
649
|
filter,
|
|
646
|
-
update: { $setOnInsert: setOnInsert },
|
|
650
|
+
update: Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined),
|
|
647
651
|
upsert: true
|
|
648
652
|
};
|
|
649
653
|
bulkWriteOps4insert.push({ updateOne });
|
|
650
|
-
|
|
651
|
-
const
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
654
|
+
// updateOneで再実装
|
|
655
|
+
// const replacement: WithoutId<factory.event.IAttributes<factory.eventType.ScreeningEventSeries>> = attributes;
|
|
656
|
+
// const replaceOne: ReplaceOneModel<factory.event.IAttributes<factory.eventType.ScreeningEventSeries>> = {
|
|
657
|
+
// filter,
|
|
658
|
+
// replacement,
|
|
659
|
+
// upsert: true
|
|
660
|
+
// };
|
|
661
|
+
// bulkWriteOps.push({ replaceOne });
|
|
657
662
|
});
|
|
658
663
|
}
|
|
659
|
-
if (
|
|
664
|
+
if (bulkWriteOps4insert.length > 0) {
|
|
660
665
|
const bulkWriteResult4insert = yield this.eventModel.bulkWrite(bulkWriteOps4insert, { ordered: false });
|
|
661
|
-
const bulkWriteResult =
|
|
666
|
+
// const bulkWriteResult = await this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
662
667
|
// modifiedの場合upsertedIdsに含まれないので、idを検索する
|
|
663
668
|
const modifiedEvents = yield this.eventModel.find({ $or: queryFilters }, { _id: 1 })
|
|
664
669
|
.exec();
|
|
665
|
-
return { bulkWriteResult4insert,
|
|
670
|
+
return { bulkWriteResult4insert, modifiedEvents };
|
|
666
671
|
}
|
|
667
672
|
});
|
|
668
673
|
}
|
|
@@ -37,7 +37,9 @@ export declare class MongoRepository {
|
|
|
37
37
|
constructor(connection: Connection);
|
|
38
38
|
static CREATE_MONGO_CONDITIONS(params: factory.offerCatalog.ISearchConditions): any[];
|
|
39
39
|
save(params: factory.offerCatalog.IOfferCatalog & {
|
|
40
|
-
$unset?:
|
|
40
|
+
$unset?: {
|
|
41
|
+
[key in keyof factory.offerCatalog.IOfferCatalog]?: 1;
|
|
42
|
+
};
|
|
41
43
|
}): Promise<{
|
|
42
44
|
id: string;
|
|
43
45
|
}>;
|
|
@@ -50,8 +52,12 @@ export declare class MongoRepository {
|
|
|
50
52
|
/**
|
|
51
53
|
* コードをキーにして冪等置換(2023-12-14~)
|
|
52
54
|
*/
|
|
53
|
-
upsertManyByIdentifier(params:
|
|
54
|
-
|
|
55
|
+
upsertManyByIdentifier(params: {
|
|
56
|
+
$set: factory.offerCatalog.IOfferCatalog;
|
|
57
|
+
$unset?: {
|
|
58
|
+
[key in keyof factory.offerCatalog.IOfferCatalog]?: 1;
|
|
59
|
+
};
|
|
60
|
+
}[]): Promise<{
|
|
55
61
|
bulkWriteResult: BulkWriteResult;
|
|
56
62
|
modifiedCatalogs: {
|
|
57
63
|
id: string;
|
|
@@ -176,49 +176,45 @@ class MongoRepository {
|
|
|
176
176
|
) {
|
|
177
177
|
return __awaiter(this, void 0, void 0, function* () {
|
|
178
178
|
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
179
|
-
// replaceOneでは_idを指定できないので、updateOne(setOnInsert)->replaceOneの2段階でbulkWriteを実行する
|
|
180
|
-
const bulkWriteOps4insert = [];
|
|
181
179
|
const bulkWriteOps = [];
|
|
182
180
|
const queryFilters = [];
|
|
183
181
|
if (Array.isArray(params)) {
|
|
184
|
-
params.forEach((
|
|
185
|
-
const { id } =
|
|
186
|
-
if (typeof
|
|
182
|
+
params.forEach(({ $set, $unset }) => {
|
|
183
|
+
const { id, identifier, project, typeOf } = $set, setFields = __rest($set, ["id", "identifier", "project", "typeOf"]);
|
|
184
|
+
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
187
185
|
throw new factory.errors.ArgumentNull('identifier');
|
|
188
186
|
}
|
|
189
187
|
// リソースのユニークネスを保証するfilter
|
|
190
188
|
const filter = {
|
|
191
|
-
'project.id': { $eq:
|
|
192
|
-
identifier: { $eq:
|
|
189
|
+
'project.id': { $eq: project.id },
|
|
190
|
+
identifier: { $eq: identifier }
|
|
193
191
|
};
|
|
194
192
|
queryFilters.push({
|
|
195
|
-
'project.id': { $eq:
|
|
196
|
-
identifier: { $eq:
|
|
193
|
+
'project.id': { $eq: project.id },
|
|
194
|
+
identifier: { $eq: identifier }
|
|
197
195
|
});
|
|
198
196
|
const newId = uniqid();
|
|
199
|
-
const setOnInsert =
|
|
197
|
+
const setOnInsert = {
|
|
198
|
+
identifier,
|
|
199
|
+
project,
|
|
200
|
+
typeOf,
|
|
201
|
+
_id: newId
|
|
202
|
+
};
|
|
200
203
|
const updateOne = {
|
|
201
204
|
filter,
|
|
202
|
-
update: { $setOnInsert: setOnInsert },
|
|
205
|
+
update: Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined),
|
|
203
206
|
upsert: true
|
|
204
207
|
};
|
|
205
|
-
|
|
206
|
-
const replacement = savingOfferCatalog;
|
|
207
|
-
const replaceOne = {
|
|
208
|
-
filter,
|
|
209
|
-
replacement,
|
|
210
|
-
upsert: false
|
|
211
|
-
};
|
|
212
|
-
bulkWriteOps.push({ replaceOne });
|
|
208
|
+
bulkWriteOps.push({ updateOne });
|
|
213
209
|
});
|
|
214
210
|
}
|
|
215
211
|
if (bulkWriteOps.length > 0) {
|
|
216
|
-
const bulkWriteResult4insert = yield this.offerCatalogModel.bulkWrite(bulkWriteOps4insert, { ordered: false });
|
|
217
212
|
const bulkWriteResult = yield this.offerCatalogModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
213
|
+
// const bulkWriteResult = await this.offerCatalogModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
218
214
|
// modifiedの場合upsertedIdsに含まれないので、idを検索する
|
|
219
215
|
const modifiedCatalogs = yield this.offerCatalogModel.find({ $or: queryFilters }, { _id: 1 })
|
|
220
216
|
.exec();
|
|
221
|
-
return {
|
|
217
|
+
return { bulkWriteResult, modifiedCatalogs };
|
|
222
218
|
}
|
|
223
219
|
});
|
|
224
220
|
}
|
|
@@ -231,45 +227,6 @@ class MongoRepository {
|
|
|
231
227
|
.exec();
|
|
232
228
|
});
|
|
233
229
|
}
|
|
234
|
-
// /**
|
|
235
|
-
// * 型を統一する
|
|
236
|
-
// */
|
|
237
|
-
// public async optimizeAll(): Promise<void> {
|
|
238
|
-
// let result = await this.offerCatalogModel.updateMany(
|
|
239
|
-
// { typeOf: { $ne: 'OfferCatalog' } },
|
|
240
|
-
// { $set: { typeOf: 'OfferCatalog' } }
|
|
241
|
-
// )
|
|
242
|
-
// .exec();
|
|
243
|
-
// // tslint:disable-next-line:no-console
|
|
244
|
-
// console.log(result);
|
|
245
|
-
// result = await this.offerCatalogModel.updateMany(
|
|
246
|
-
// { ticketTypes: { $exists: true } },
|
|
247
|
-
// {
|
|
248
|
-
// $unset: { ticketTypes: 1 }
|
|
249
|
-
// }
|
|
250
|
-
// )
|
|
251
|
-
// .exec();
|
|
252
|
-
// // tslint:disable-next-line:no-console
|
|
253
|
-
// console.log(result);
|
|
254
|
-
// result = await this.offerCatalogModel.updateMany(
|
|
255
|
-
// { id: { $exists: true } },
|
|
256
|
-
// {
|
|
257
|
-
// $unset: { id: 1 }
|
|
258
|
-
// }
|
|
259
|
-
// )
|
|
260
|
-
// .exec();
|
|
261
|
-
// // tslint:disable-next-line:no-console
|
|
262
|
-
// console.log(result);
|
|
263
|
-
// result = await this.offerCatalogModel.updateMany(
|
|
264
|
-
// { 'itemOffered.serviceType': { $exists: true } },
|
|
265
|
-
// {
|
|
266
|
-
// $unset: { 'itemOffered.serviceType': 1 }
|
|
267
|
-
// }
|
|
268
|
-
// )
|
|
269
|
-
// .exec();
|
|
270
|
-
// // tslint:disable-next-line:no-console
|
|
271
|
-
// console.log(result);
|
|
272
|
-
// }
|
|
273
230
|
updateManyById(params) {
|
|
274
231
|
return __awaiter(this, void 0, void 0, function* () {
|
|
275
232
|
if (!Array.isArray(params.id.$in) || params.id.$in.length === 0) {
|
|
@@ -278,7 +278,7 @@ function saveScreeningEventSeries(params) {
|
|
|
278
278
|
yield repos.creativeWork.upsertMoviesByIdentifier(saveParams.map((saveScreeningEventSeriesParams) => {
|
|
279
279
|
var _a;
|
|
280
280
|
return {
|
|
281
|
-
|
|
281
|
+
$set: Object.assign(Object.assign({ typeOf: factory.creativeWorkType.Movie, project: params.project, identifier: saveScreeningEventSeriesParams.attributes.workPerformed.identifier, name: { ja: (_a = saveScreeningEventSeriesParams.attributes.workPerformed.name) === null || _a === void 0 ? void 0 : _a.ja }, offers: { typeOf: factory.offerType.Offer } }, (typeof saveScreeningEventSeriesParams.attributes.workPerformed.contentRating === 'string')
|
|
282
282
|
? { contentRating: saveScreeningEventSeriesParams.attributes.workPerformed.contentRating }
|
|
283
283
|
: undefined), (typeof saveScreeningEventSeriesParams.attributes.workPerformed.duration === 'string')
|
|
284
284
|
? { duration: saveScreeningEventSeriesParams.attributes.workPerformed.duration }
|
package/package.json
CHANGED