@chevre/domain 23.2.0-alpha.36 → 23.2.0-alpha.37
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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as moment from 'moment';
|
|
3
3
|
import * as mongoose from 'mongoose';
|
|
4
4
|
|
|
5
|
-
import { chevre } from '
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
6
|
|
|
7
7
|
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
8
8
|
|
|
@@ -19,14 +19,18 @@ async function main() {
|
|
|
19
19
|
eventStatus: chevre.factory.eventStatusType.EventScheduled,
|
|
20
20
|
videoFormat: [],
|
|
21
21
|
soundFormat: [],
|
|
22
|
+
subEvent: {
|
|
23
|
+
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
24
|
+
videoFormat: []
|
|
25
|
+
},
|
|
22
26
|
kanaName: '',
|
|
23
27
|
startDate: moment('2023-12-08T15:00:00Z')
|
|
24
28
|
.toDate(),
|
|
25
|
-
endDate: moment('
|
|
29
|
+
endDate: moment('2027-12-08T15:00:00Z')
|
|
26
30
|
.toDate(),
|
|
27
31
|
typeOf: chevre.factory.eventType.ScreeningEventSeries,
|
|
28
32
|
duration: 'PT2H',
|
|
29
|
-
name: { ja: '
|
|
33
|
+
name: { ja: '男はつらいよ 純情篇', en: 'xxx' },
|
|
30
34
|
offers: {
|
|
31
35
|
typeOf: chevre.factory.offerType.Offer
|
|
32
36
|
},
|
|
@@ -53,46 +57,47 @@ async function main() {
|
|
|
53
57
|
headline: { ja: 'xxx', en: '' }
|
|
54
58
|
},
|
|
55
59
|
$unset: {}
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
$set: {
|
|
59
|
-
eventStatus: chevre.factory.eventStatusType.EventScheduled,
|
|
60
|
-
videoFormat: [],
|
|
61
|
-
soundFormat: [],
|
|
62
|
-
kanaName: '',
|
|
63
|
-
startDate: moment('2023-12-08T15:00:00Z')
|
|
64
|
-
.toDate(),
|
|
65
|
-
endDate: moment('2123-12-08T15:00:00Z')
|
|
66
|
-
.toDate(),
|
|
67
|
-
typeOf: chevre.factory.eventType.ScreeningEventSeries,
|
|
68
|
-
duration: 'PT2H',
|
|
69
|
-
name: { ja: '名探偵コナン ゼロの執行人', en: 'Detective Conan Zero Enforcer' },
|
|
70
|
-
offers: {
|
|
71
|
-
typeOf: chevre.factory.offerType.Offer
|
|
72
|
-
},
|
|
73
|
-
project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
|
|
74
|
-
additionalProperty: [
|
|
75
|
-
],
|
|
76
|
-
location: {
|
|
77
|
-
branchCode: '118',
|
|
78
|
-
id: '5bfb841d5a78d7948369979a',
|
|
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: '6'
|
|
91
|
-
},
|
|
92
|
-
organizer: { id: '59d20831e53ebc2b4e774466' }
|
|
93
|
-
}
|
|
94
60
|
}
|
|
95
|
-
|
|
61
|
+
// {
|
|
62
|
+
// $set: {
|
|
63
|
+
// eventStatus: chevre.factory.eventStatusType.EventScheduled,
|
|
64
|
+
// videoFormat: [],
|
|
65
|
+
// soundFormat: [],
|
|
66
|
+
// kanaName: '',
|
|
67
|
+
// startDate: moment('2023-12-08T15:00:00Z')
|
|
68
|
+
// .toDate(),
|
|
69
|
+
// endDate: moment('2123-12-08T15:00:00Z')
|
|
70
|
+
// .toDate(),
|
|
71
|
+
// typeOf: chevre.factory.eventType.ScreeningEventSeries,
|
|
72
|
+
// duration: 'PT2H',
|
|
73
|
+
// name: { ja: '男はつらいよ 純情篇', en: 'xxx' },
|
|
74
|
+
// offers: {
|
|
75
|
+
// typeOf: chevre.factory.offerType.Offer
|
|
76
|
+
// },
|
|
77
|
+
// project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
|
|
78
|
+
// additionalProperty: [
|
|
79
|
+
// ],
|
|
80
|
+
// location: {
|
|
81
|
+
// branchCode: '118',
|
|
82
|
+
// id: '5bfb841d5a78d7948369979a',
|
|
83
|
+
// name: { ja: 'シネモーション赤坂 ', en: 'CineMotion Akasaka' },
|
|
84
|
+
// typeOf: chevre.factory.placeType.MovieTheater
|
|
85
|
+
// },
|
|
86
|
+
// workPerformed: {
|
|
87
|
+
// typeOf: chevre.factory.creativeWorkType.Movie,
|
|
88
|
+
// id: '5bfb841d5a78d79483699801',
|
|
89
|
+
// identifier: '071953',
|
|
90
|
+
// name: {
|
|
91
|
+
// ja: '男はつらいよ 純情篇'
|
|
92
|
+
// },
|
|
93
|
+
// duration: 'PT1H29M',
|
|
94
|
+
// version: '6'
|
|
95
|
+
// },
|
|
96
|
+
// organizer: { id: '59d20831e53ebc2b4e774466' }
|
|
97
|
+
// }
|
|
98
|
+
// }
|
|
99
|
+
],
|
|
100
|
+
{ upsert: false }
|
|
96
101
|
);
|
|
97
102
|
console.log('result:', result);
|
|
98
103
|
}
|
|
@@ -27,17 +27,23 @@ export declare class EventSeriesRepo {
|
|
|
27
27
|
attributes: factory.eventSeries.IAttributes;
|
|
28
28
|
}[]): Promise<BulkWriteResult | void>;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* 施設+コンテンツ+バージョンをキーにして冪等置換
|
|
31
31
|
*/
|
|
32
32
|
upsertByVersion(params: {
|
|
33
33
|
$set: factory.eventSeries.IAttributes;
|
|
34
34
|
$unset?: IUnset;
|
|
35
|
-
}[]
|
|
36
|
-
|
|
35
|
+
}[], options: {
|
|
36
|
+
/**
|
|
37
|
+
* falseの場合setOnInsertのみ
|
|
38
|
+
* trueの場合setOnInsert+setのみ
|
|
39
|
+
*/
|
|
40
|
+
upsert: boolean;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
bulkWriteResult?: BulkWriteResult;
|
|
37
43
|
modifiedEvents: {
|
|
38
44
|
id: string;
|
|
39
45
|
}[];
|
|
40
|
-
}
|
|
46
|
+
}>;
|
|
41
47
|
saveEventSeries(params: {
|
|
42
48
|
id?: string;
|
|
43
49
|
attributes: factory.eventSeries.IAttributes;
|
|
@@ -298,13 +298,13 @@ class EventSeriesRepo {
|
|
|
298
298
|
});
|
|
299
299
|
}
|
|
300
300
|
/**
|
|
301
|
-
*
|
|
301
|
+
* 施設+コンテンツ+バージョンをキーにして冪等置換
|
|
302
302
|
*/
|
|
303
|
-
|
|
304
|
-
upsertByVersion(params) {
|
|
303
|
+
upsertByVersion(params, options) {
|
|
305
304
|
return __awaiter(this, void 0, void 0, function* () {
|
|
305
|
+
const { upsert } = options;
|
|
306
306
|
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
307
|
-
const
|
|
307
|
+
const bulkWriteOps = [];
|
|
308
308
|
const queryFilters = [];
|
|
309
309
|
if (Array.isArray(params)) {
|
|
310
310
|
params.forEach(({ $set, $unset }) => {
|
|
@@ -333,21 +333,45 @@ class EventSeriesRepo {
|
|
|
333
333
|
typeOf,
|
|
334
334
|
_id: uniqid()
|
|
335
335
|
};
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
336
|
+
let updateOne;
|
|
337
|
+
if (upsert === true) {
|
|
338
|
+
updateOne = {
|
|
339
|
+
filter,
|
|
340
|
+
update: Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined),
|
|
341
|
+
upsert: true
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
updateOne = {
|
|
346
|
+
filter,
|
|
347
|
+
update: {
|
|
348
|
+
$setOnInsert: Object.assign(Object.assign({}, setOnInsert), setFields)
|
|
349
|
+
},
|
|
350
|
+
upsert: true
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
bulkWriteOps.push({ updateOne });
|
|
342
354
|
});
|
|
343
355
|
}
|
|
344
|
-
if (
|
|
345
|
-
const
|
|
346
|
-
//
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
356
|
+
if (bulkWriteOps.length > 0) {
|
|
357
|
+
const bulkWriteResult = yield this.eventSeriesModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
358
|
+
// upsert:falseの場合、upsertedIdsのみmodifiedEventsとして返せばよい(2026-01-27~)
|
|
359
|
+
if (!upsert) {
|
|
360
|
+
// BulkWriteResult -> upsertedIds: { '0': '7iri6p4m54k0r3g' }
|
|
361
|
+
return {
|
|
362
|
+
bulkWriteResult,
|
|
363
|
+
modifiedEvents: Object.values(bulkWriteResult.upsertedIds)
|
|
364
|
+
.map((id) => ({ id: String(id) }))
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
// modifiedの場合upsertedIdsに含まれないので、idを検索する
|
|
369
|
+
const modifiedEvents = yield this.eventSeriesModel.find({ $or: queryFilters }, { _id: 1 })
|
|
370
|
+
.exec();
|
|
371
|
+
return { bulkWriteResult, modifiedEvents };
|
|
372
|
+
}
|
|
350
373
|
}
|
|
374
|
+
return { modifiedEvents: [] };
|
|
351
375
|
});
|
|
352
376
|
}
|
|
353
377
|
saveEventSeries(params) {
|
package/package.json
CHANGED