@chevre/domain 23.0.0-alpha.27 → 23.0.0-alpha.28
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/categoryCode/checkUniqueness.ts +69 -0
- package/example/src/chevre/movieTicketType/deleteOldMovieTicketTypes.ts +15 -0
- package/example/src/chevre/reIndex.ts +2 -1
- package/lib/chevre/repo/mongoose/schemas/categoryCode.js +34 -23
- package/lib/chevre/repo/movieTicketType.d.ts +1 -0
- package/lib/chevre/repo/movieTicketType.js +14 -2
- package/package.json +3 -3
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// tslint:disable:no-console no-magic-numbers
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// tslint:disable-next-line:max-func-body-length
|
|
7
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
+
|
|
10
|
+
const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const cursor = categoryCodeRepo.getCursor(
|
|
13
|
+
{
|
|
14
|
+
// _id: { $eq: '68f5d32176b5f6b689ff24a6' },
|
|
15
|
+
// 'project.id': { $eq: project.id },
|
|
16
|
+
// 'additionalProperty.name': { $exists: true, $eq: PROPERTY_NAME }
|
|
17
|
+
'inCodeSet.identifier': { $ne: chevre.factory.movieTicketType.CategorySetIdentifier.MovieTicketType }
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
_id: 1,
|
|
21
|
+
codeValue: 1,
|
|
22
|
+
project: 1,
|
|
23
|
+
inCodeSet: 1,
|
|
24
|
+
name: 1,
|
|
25
|
+
typeOf: 1
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
console.log('docs found');
|
|
29
|
+
|
|
30
|
+
let i = 0;
|
|
31
|
+
let notUniqueCount = 0;
|
|
32
|
+
await cursor.eachAsync(async (doc) => {
|
|
33
|
+
i += 1;
|
|
34
|
+
const categoryCode: Pick<
|
|
35
|
+
chevre.factory.categoryCode.ICategoryCode,
|
|
36
|
+
'codeValue' | 'id' | 'inCodeSet' | 'name' | 'project' | 'typeOf'
|
|
37
|
+
> = doc.toObject();
|
|
38
|
+
|
|
39
|
+
// console.log('unique?', categoryCode.project.id, categoryCode.id, categoryCode.codeValue, i);
|
|
40
|
+
|
|
41
|
+
const sameCodeValues = (await categoryCodeRepo.projectCategoryCodeFields(
|
|
42
|
+
{
|
|
43
|
+
project: { id: { $eq: categoryCode.project.id } },
|
|
44
|
+
codeValue: { $eq: categoryCode.codeValue }
|
|
45
|
+
// inCodeSet:{identifier:{$}}
|
|
46
|
+
},
|
|
47
|
+
['codeValue', 'inCodeSet']
|
|
48
|
+
)).filter(
|
|
49
|
+
({ inCodeSet }) => <unknown>inCodeSet.identifier !== chevre.factory.movieTicketType.CategorySetIdentifier.MovieTicketType
|
|
50
|
+
);
|
|
51
|
+
// console.log(sameCodeValues, 'sameCodeValues found', categoryCode.project.id, categoryCode.id, categoryCode.codeValue, i);
|
|
52
|
+
|
|
53
|
+
const isUnique = sameCodeValues.length === 1;
|
|
54
|
+
if (isUnique) {
|
|
55
|
+
// console.log(
|
|
56
|
+
// 'unique.', categoryCode.project.id, categoryCode.id, categoryCode.codeValue, i);
|
|
57
|
+
} else {
|
|
58
|
+
notUniqueCount += 1;
|
|
59
|
+
console.log('not unique.', categoryCode.project.id, categoryCode.id, categoryCode.codeValue, i);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
console.log(i, 'docs checked');
|
|
64
|
+
console.log(notUniqueCount, 'docs not unique');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
main()
|
|
68
|
+
.then()
|
|
69
|
+
.catch(console.error);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// tslint:disable:no-console no-magic-numbers
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
+
|
|
9
|
+
const movieTicketTypeRepo = await chevre.repository.MovieTicketType.createInstance(mongoose.connection);
|
|
10
|
+
await movieTicketTypeRepo.deleteOldMovieTicketTypes(mongoose.connection);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
main()
|
|
14
|
+
.then()
|
|
15
|
+
.catch(console.error);
|
|
@@ -11,7 +11,8 @@ mongoose.Model.on('index', (...args) => {
|
|
|
11
11
|
async function main() {
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
|
-
await chevre.repository.
|
|
14
|
+
await chevre.repository.CategoryCode.createInstance(mongoose.connection);
|
|
15
|
+
// await chevre.repository.MovieTicketType.createInstance(mongoose.connection);
|
|
15
16
|
console.log('success!');
|
|
16
17
|
}
|
|
17
18
|
|
|
@@ -4,7 +4,6 @@ exports.modelName = exports.indexes = void 0;
|
|
|
4
4
|
exports.createSchema = createSchema;
|
|
5
5
|
const mongoose_1 = require("mongoose");
|
|
6
6
|
const writeConcern_1 = require("../writeConcern");
|
|
7
|
-
const factory = require("../../../factory");
|
|
8
7
|
const settings_1 = require("../../../settings");
|
|
9
8
|
const modelName = 'CategoryCode';
|
|
10
9
|
exports.modelName = modelName;
|
|
@@ -100,37 +99,49 @@ const indexes = [
|
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
],
|
|
103
|
-
//
|
|
104
|
-
[
|
|
105
|
-
{
|
|
106
|
-
'project.id': 1,
|
|
107
|
-
'inCodeSet.identifier': 1,
|
|
108
|
-
codeValue: 1
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
unique: true,
|
|
112
|
-
name: 'uniqueByCodeValueAndInCodeSet',
|
|
113
|
-
partialFilterExpression: {
|
|
114
|
-
// tslint:disable-next-line:no-null-keyword
|
|
115
|
-
'paymentMethod.typeOf': null
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
],
|
|
102
|
+
// 決済カード区分をコレクション分離したので、reIndex unique index(2025-11-05~)
|
|
119
103
|
[
|
|
120
104
|
{
|
|
121
105
|
'project.id': 1,
|
|
122
|
-
'
|
|
106
|
+
'inCodeSet.identifier': 1, // ssktsでのみ区分分類をまたいで重複がある
|
|
123
107
|
codeValue: 1
|
|
124
108
|
},
|
|
125
109
|
{
|
|
126
110
|
unique: true,
|
|
127
|
-
name: '
|
|
128
|
-
partialFilterExpression: {
|
|
129
|
-
'inCodeSet.identifier': { $eq: factory.movieTicketType.CategorySetIdentifier.MovieTicketType },
|
|
130
|
-
'paymentMethod.typeOf': { $exists: true }
|
|
131
|
-
}
|
|
111
|
+
name: 'uniqueByCodeValue'
|
|
132
112
|
}
|
|
133
113
|
]
|
|
114
|
+
// add unique index(2024-11-14~)
|
|
115
|
+
// [
|
|
116
|
+
// {
|
|
117
|
+
// 'project.id': 1,
|
|
118
|
+
// 'inCodeSet.identifier': 1,
|
|
119
|
+
// codeValue: 1
|
|
120
|
+
// },
|
|
121
|
+
// {
|
|
122
|
+
// unique: true,
|
|
123
|
+
// name: 'uniqueByCodeValueAndInCodeSet',
|
|
124
|
+
// partialFilterExpression: {
|
|
125
|
+
// // tslint:disable-next-line:no-null-keyword
|
|
126
|
+
// 'paymentMethod.typeOf': null
|
|
127
|
+
// }
|
|
128
|
+
// }
|
|
129
|
+
// ],
|
|
130
|
+
// [
|
|
131
|
+
// {
|
|
132
|
+
// 'project.id': 1,
|
|
133
|
+
// 'paymentMethod.typeOf': 1,
|
|
134
|
+
// codeValue: 1
|
|
135
|
+
// },
|
|
136
|
+
// {
|
|
137
|
+
// unique: true,
|
|
138
|
+
// name: 'uniqueByCodeValueAndPaymentMethod',
|
|
139
|
+
// partialFilterExpression: {
|
|
140
|
+
// 'inCodeSet.identifier': { $eq: factory.movieTicketType.CategorySetIdentifier.MovieTicketType },
|
|
141
|
+
// 'paymentMethod.typeOf': { $exists: true }
|
|
142
|
+
// }
|
|
143
|
+
// }
|
|
144
|
+
// ]
|
|
134
145
|
];
|
|
135
146
|
exports.indexes = indexes;
|
|
136
147
|
/**
|
|
@@ -275,7 +275,7 @@ class MovieTicketTypeRepo {
|
|
|
275
275
|
const movieTicketType = doc.toObject();
|
|
276
276
|
const { additionalProperty } = movieTicketType, docWithoutAdditinalProperty = __rest(movieTicketType, ["additionalProperty"]);
|
|
277
277
|
// tslint:disable-next-line:no-console
|
|
278
|
-
console.log('upserting...',
|
|
278
|
+
console.log('upserting...', docWithoutAdditinalProperty, i);
|
|
279
279
|
const result = yield movieTicketTypeModel.findOneAndReplace({ _id: { $eq: doc._id } }, docWithoutAdditinalProperty, {
|
|
280
280
|
upsert: true,
|
|
281
281
|
projection: { _id: 1 }
|
|
@@ -283,11 +283,23 @@ class MovieTicketTypeRepo {
|
|
|
283
283
|
.exec();
|
|
284
284
|
// await additionalPropertyRepo.save({ attributes: additionalProperty });
|
|
285
285
|
// tslint:disable-next-line:no-console
|
|
286
|
-
console.log('upserted', result, movieTicketType.id, movieTicketType.project.id, movieTicketType.codeValue);
|
|
286
|
+
console.log('upserted', result, movieTicketType.id, movieTicketType.project.id, movieTicketType.codeValue, i);
|
|
287
287
|
}));
|
|
288
288
|
// tslint:disable-next-line:no-console
|
|
289
289
|
console.log(i, 'docs checked');
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
|
+
// tslint:disable-next-line:prefer-function-over-method
|
|
293
|
+
deleteOldMovieTicketTypes(connection) {
|
|
294
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
295
|
+
const oldCategoryCodeModel = connection.model(categoryCode_1.modelName, (0, categoryCode_1.createSchema)());
|
|
296
|
+
const result = yield oldCategoryCodeModel.deleteMany({
|
|
297
|
+
'inCodeSet.identifier': { $eq: factory.movieTicketType.CategorySetIdentifier.MovieTicketType }
|
|
298
|
+
})
|
|
299
|
+
.exec();
|
|
300
|
+
// tslint:disable-next-line:no-console
|
|
301
|
+
console.log(result);
|
|
302
|
+
});
|
|
303
|
+
}
|
|
292
304
|
}
|
|
293
305
|
exports.MovieTicketTypeRepo = MovieTicketTypeRepo;
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "5.2.0-alpha.
|
|
15
|
-
"@cinerino/sdk": "12.7.0-alpha.
|
|
14
|
+
"@chevre/factory": "5.2.0-alpha.4",
|
|
15
|
+
"@cinerino/sdk": "12.7.0-alpha.1",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.1",
|
|
18
18
|
"@sendgrid/client": "8.1.4",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "23.0.0-alpha.
|
|
118
|
+
"version": "23.0.0-alpha.28"
|
|
119
119
|
}
|