@chevre/domain 21.15.0 → 21.16.0-alpha.1
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.
|
@@ -14,6 +14,8 @@ async function main() {
|
|
|
14
14
|
|
|
15
15
|
const cursor = orderRepo.getCursor(
|
|
16
16
|
{
|
|
17
|
+
'paymentMethods.paymentMethodId': { $exists: true },
|
|
18
|
+
'paymentMethods.paymentMethod.identifier': { $exists: false },
|
|
17
19
|
// 'project.id': { $eq: project.id },
|
|
18
20
|
// orderNumber: { $eq: 'KNR1-3961294-9087043' },
|
|
19
21
|
orderDate: {
|
|
@@ -48,7 +50,8 @@ async function main() {
|
|
|
48
50
|
const noPayment = order.paymentMethods.length === 0;
|
|
49
51
|
const alreadyMigrated = order.paymentMethods.every((invoice) => {
|
|
50
52
|
return typeof invoice.paymentMethod?.identifier === 'string'
|
|
51
|
-
&& invoice.paymentMethod.
|
|
53
|
+
&& invoice.paymentMethod?.identifier.length > 0;
|
|
54
|
+
// && invoice.paymentMethod.identifier === (<any>invoice).typeOf;
|
|
52
55
|
});
|
|
53
56
|
|
|
54
57
|
if (noPayment) {
|
|
@@ -10,34 +10,12 @@ async function main() {
|
|
|
10
10
|
|
|
11
11
|
let updateResult: any;
|
|
12
12
|
|
|
13
|
-
const
|
|
14
|
-
updateResult = await
|
|
13
|
+
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
14
|
+
updateResult = await orderRepo.unsetUnnecessaryFields({
|
|
15
15
|
filter: {
|
|
16
|
-
|
|
17
|
-
typeOf: { $eq: chevre.factory.organizationType.Corporation },
|
|
18
|
-
areaServed: { $exists: true }
|
|
16
|
+
'paymentMethods.typeOf': { $exists: true }
|
|
19
17
|
},
|
|
20
|
-
$unset: {
|
|
21
|
-
});
|
|
22
|
-
console.log('unset processed.', updateResult);
|
|
23
|
-
|
|
24
|
-
const placeRepo = await chevre.repository.Place.createInstance(mongoose.connection);
|
|
25
|
-
updateResult = await placeRepo.unsetUnnecessaryFieldsFromMovieTheater({
|
|
26
|
-
filter: {
|
|
27
|
-
$and: [
|
|
28
|
-
{ typeOf: { $eq: chevre.factory.placeType.MovieTheater } },
|
|
29
|
-
{
|
|
30
|
-
$or: [
|
|
31
|
-
{ 'offers.project': { $exists: true } },
|
|
32
|
-
{ 'offers.priceCurrency': { $exists: true } }
|
|
33
|
-
]
|
|
34
|
-
}
|
|
35
|
-
]
|
|
36
|
-
},
|
|
37
|
-
$unset: {
|
|
38
|
-
'offers.project': 1,
|
|
39
|
-
'offers.priceCurrency': 1
|
|
40
|
-
}
|
|
18
|
+
$unset: { 'paymentMethods.$[].typeOf': 1 }
|
|
41
19
|
});
|
|
42
20
|
console.log('unset processed.', updateResult);
|
|
43
21
|
}
|
|
@@ -22,8 +22,15 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import type { Connection } from 'mongoose';
|
|
25
|
+
import type { Connection, FilterQuery } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
|
+
type IKeyOfProjection = keyof factory.order.IOrder | '_id';
|
|
28
|
+
type IProjection4searchWithUnwoundAcceptedOffer = {
|
|
29
|
+
[key in keyof Omit<factory.order.IOrder, 'acceptedOffers'>]?: 1;
|
|
30
|
+
} & {
|
|
31
|
+
_id?: 0 | 1;
|
|
32
|
+
acceptedOffers?: ['$acceptedOffers'];
|
|
33
|
+
};
|
|
27
34
|
/**
|
|
28
35
|
* 注文リポジトリ
|
|
29
36
|
*/
|
|
@@ -87,8 +94,8 @@ export declare class MongoRepository {
|
|
|
87
94
|
}): Promise<void>;
|
|
88
95
|
findById(params: {
|
|
89
96
|
id: string;
|
|
90
|
-
inclusion:
|
|
91
|
-
exclusion:
|
|
97
|
+
inclusion: IKeyOfProjection[];
|
|
98
|
+
exclusion: IKeyOfProjection[];
|
|
92
99
|
}): Promise<factory.order.IOrder>;
|
|
93
100
|
/**
|
|
94
101
|
* 注文番号から注文を取得する
|
|
@@ -101,8 +108,8 @@ export declare class MongoRepository {
|
|
|
101
108
|
seller?: {
|
|
102
109
|
id?: string;
|
|
103
110
|
};
|
|
104
|
-
inclusion:
|
|
105
|
-
exclusion:
|
|
111
|
+
inclusion: IKeyOfProjection[];
|
|
112
|
+
exclusion: IKeyOfProjection[];
|
|
106
113
|
}): Promise<factory.order.IOrder>;
|
|
107
114
|
findByOrderNumberAndReservationId(params: {
|
|
108
115
|
project: {
|
|
@@ -125,7 +132,7 @@ export declare class MongoRepository {
|
|
|
125
132
|
* 注文を検索する
|
|
126
133
|
*/
|
|
127
134
|
search(params: factory.order.ISearchConditions, projection?: {
|
|
128
|
-
[key
|
|
135
|
+
[key in IKeyOfProjection]?: 0 | 1;
|
|
129
136
|
}): Promise<factory.order.IOrder[]>;
|
|
130
137
|
/**
|
|
131
138
|
* 注文の受入オファーIDリストを検索する
|
|
@@ -134,9 +141,7 @@ export declare class MongoRepository {
|
|
|
134
141
|
/**
|
|
135
142
|
* オファー展開の注文検索
|
|
136
143
|
*/
|
|
137
|
-
searchWithUnwoundAcceptedOffer(params: factory.order.ISearchConditions, projection?: {
|
|
138
|
-
[key: string]: any;
|
|
139
|
-
}): Promise<Omit<factory.order.IOrder[], 'acceptedOffers'> & {
|
|
144
|
+
searchWithUnwoundAcceptedOffer(params: factory.order.ISearchConditions, projection?: IProjection4searchWithUnwoundAcceptedOffer): Promise<Omit<factory.order.IOrder[], 'acceptedOffers'> & {
|
|
140
145
|
acceptedOffers?: factory.order.IAcceptedOffer<factory.order.IItemOffered> | factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
|
|
141
146
|
}>;
|
|
142
147
|
/**
|
|
@@ -167,4 +172,9 @@ export declare class MongoRepository {
|
|
|
167
172
|
priceSpecification: factory.order.ITicketPriceSpecification;
|
|
168
173
|
}[]>;
|
|
169
174
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
175
|
+
unsetUnnecessaryFields(params: {
|
|
176
|
+
filter: FilterQuery<any>;
|
|
177
|
+
$unset: any;
|
|
178
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
170
179
|
}
|
|
180
|
+
export {};
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -565,7 +565,9 @@ class MongoRepository {
|
|
|
565
565
|
}
|
|
566
566
|
const paymentMethodsTypeOfIn = (_20 = params.paymentMethods) === null || _20 === void 0 ? void 0 : _20.typeOfs;
|
|
567
567
|
if (Array.isArray(paymentMethodsTypeOfIn)) {
|
|
568
|
-
|
|
568
|
+
// paymentMethod.identifierで検索(2023-11-15~)
|
|
569
|
+
// andConditions.push({ 'paymentMethods.typeOf': { $exists: true, $in: paymentMethodsTypeOfIn } });
|
|
570
|
+
andConditions.push({ 'paymentMethods.paymentMethod.identifier': { $exists: true, $in: paymentMethodsTypeOfIn } });
|
|
569
571
|
}
|
|
570
572
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
571
573
|
/* istanbul ignore else */
|
|
@@ -1097,5 +1099,11 @@ class MongoRepository {
|
|
|
1097
1099
|
.sort({ orderDate: factory.sortType.Descending })
|
|
1098
1100
|
.cursor();
|
|
1099
1101
|
}
|
|
1102
|
+
unsetUnnecessaryFields(params) {
|
|
1103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1104
|
+
return this.orderModel.updateMany(params.filter, { $unset: params.$unset })
|
|
1105
|
+
.exec();
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1100
1108
|
}
|
|
1101
1109
|
exports.MongoRepository = MongoRepository;
|
package/package.json
CHANGED