@chevre/domain 21.15.0-alpha.1 → 21.15.0-alpha.10
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/migrateIAMMemberPOSRoles.ts +78 -0
- package/example/src/chevre/{migrateCategoryCodeAdditionalProperties.ts → migrateMovieTheaterAdditionalProperties.ts} +21 -21
- package/example/src/chevre/searchCategoryCodesByAggregate.ts +32 -0
- package/example/src/chevre/searchSellersByAggregate.ts +48 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +28 -14
- package/lib/chevre/repo/categoryCode.d.ts +13 -8
- package/lib/chevre/repo/categoryCode.js +66 -22
- package/lib/chevre/repo/creativeWork.d.ts +7 -8
- package/lib/chevre/repo/creativeWork.js +19 -78
- package/lib/chevre/repo/mongoose/schemas/seller.js +2 -2
- package/lib/chevre/repo/place.d.ts +10 -13
- package/lib/chevre/repo/place.js +9 -25
- package/lib/chevre/repo/seller.d.ts +18 -8
- package/lib/chevre/repo/seller.js +78 -38
- package/lib/chevre/service/assetTransaction/reserve/factory/price.js +1 -1
- package/lib/chevre/service/event.js +2 -2
- package/lib/chevre/service/offer.d.ts +2 -1
- package/lib/chevre/service/offer.js +15 -9
- package/package.json +3 -3
- package/example/src/chevre/migrateIAMMemberMemberOf.ts +0 -59
- package/example/src/chevre/searchSellers.ts +0 -28
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
const POS_CLIENT_ID = String(process.env.POS_CLIENT_ID);
|
|
8
|
+
enum ROLE_NAME {
|
|
9
|
+
Customer = 'customer',
|
|
10
|
+
POS = 'pos'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// tslint:disable-next-line:max-func-body-length
|
|
14
|
+
async function main() {
|
|
15
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
16
|
+
|
|
17
|
+
const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
|
|
18
|
+
|
|
19
|
+
const cursor = memberRepo.getCursor(
|
|
20
|
+
{
|
|
21
|
+
'member.id': { $eq: POS_CLIENT_ID }
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
// _id: 1,
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
console.log('members found');
|
|
28
|
+
|
|
29
|
+
let i = 0;
|
|
30
|
+
let updateCount = 0;
|
|
31
|
+
await cursor.eachAsync(async (doc) => {
|
|
32
|
+
i += 1;
|
|
33
|
+
const iamMember: chevre.factory.iam.IMember = doc.toObject();
|
|
34
|
+
|
|
35
|
+
const hasCustomerRole = iamMember.member.hasRole.some((role) => role.roleName === ROLE_NAME.Customer);
|
|
36
|
+
const alreadyMigrated = iamMember.member.hasRole.some((role) => role.roleName === ROLE_NAME.POS);
|
|
37
|
+
|
|
38
|
+
if (alreadyMigrated) {
|
|
39
|
+
console.log(
|
|
40
|
+
'already exist...', iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, iamMember.member.hasRole.length, 'roles', i);
|
|
41
|
+
} else {
|
|
42
|
+
if (!hasCustomerRole) {
|
|
43
|
+
console.error(
|
|
44
|
+
'has no customer role!',
|
|
45
|
+
iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, iamMember.member.hasRole.length, 'roles', i);
|
|
46
|
+
throw new Error('has no customer role!');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const newHasRole: chevre.factory.iam.IMemberHasRole = iamMember.member.hasRole;
|
|
50
|
+
newHasRole.push({ roleName: ROLE_NAME.POS, typeOf: chevre.factory.iam.RoleType.OrganizationRole });
|
|
51
|
+
console.log(
|
|
52
|
+
'updating reservation...',
|
|
53
|
+
iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, newHasRole.length, 'roles', i);
|
|
54
|
+
await memberRepo.updateByMemberId({
|
|
55
|
+
project: { id: iamMember.project.id },
|
|
56
|
+
member: {
|
|
57
|
+
id: iamMember.member.id,
|
|
58
|
+
memberOf: {
|
|
59
|
+
id: iamMember.project.id,
|
|
60
|
+
typeOf: chevre.factory.organizationType.Project
|
|
61
|
+
},
|
|
62
|
+
hasRole: newHasRole
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
updateCount += 1;
|
|
66
|
+
console.log(
|
|
67
|
+
'updated.',
|
|
68
|
+
iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, newHasRole.length, 'roles', i);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
console.log(i, 'members checked');
|
|
73
|
+
console.log(updateCount, 'members updated');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
main()
|
|
77
|
+
.then()
|
|
78
|
+
.catch(console.error);
|
|
@@ -12,10 +12,11 @@ async function main() {
|
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
14
|
const additionalPropertyRepo = await chevre.repository.AdditionalProperty.createInstance(mongoose.connection);
|
|
15
|
-
const
|
|
15
|
+
const placeRepo = await chevre.repository.Place.createInstance(mongoose.connection);
|
|
16
16
|
|
|
17
|
-
const cursor =
|
|
17
|
+
const cursor = placeRepo.getCursor(
|
|
18
18
|
{
|
|
19
|
+
typeOf: { $eq: chevre.factory.placeType.MovieTheater }
|
|
19
20
|
// 'project.id': { $eq: project.id },
|
|
20
21
|
// 'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
21
22
|
},
|
|
@@ -25,7 +26,7 @@ async function main() {
|
|
|
25
26
|
// orderDate: 1
|
|
26
27
|
}
|
|
27
28
|
);
|
|
28
|
-
console.log('
|
|
29
|
+
console.log('places found');
|
|
29
30
|
|
|
30
31
|
const additionalPropertyNames: string[] = [];
|
|
31
32
|
const projectIds: string[] = [];
|
|
@@ -36,30 +37,30 @@ async function main() {
|
|
|
36
37
|
let i = 0;
|
|
37
38
|
await cursor.eachAsync(async (doc) => {
|
|
38
39
|
i += 1;
|
|
39
|
-
const
|
|
40
|
+
const movieTheater: chevre.factory.place.movieTheater.IPlace = doc.toObject();
|
|
40
41
|
|
|
41
|
-
const additionalPropertyNamesOnResource = (Array.isArray(
|
|
42
|
-
?
|
|
42
|
+
const additionalPropertyNamesOnResource = (Array.isArray(movieTheater.additionalProperty))
|
|
43
|
+
? movieTheater.additionalProperty?.map((p) => p.name)
|
|
43
44
|
: [];
|
|
44
45
|
if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
|
|
45
46
|
console.log(
|
|
46
47
|
additionalPropertyNamesOnResource.join(','),
|
|
47
48
|
additionalPropertyNamesOnResource.length,
|
|
48
49
|
'additionalPropertyNamesOnResource found',
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
movieTheater.project.id,
|
|
51
|
+
movieTheater.branchCode
|
|
51
52
|
);
|
|
52
53
|
additionalPropertyNames.push(...additionalPropertyNamesOnResource);
|
|
53
|
-
projectIds.push(
|
|
54
|
+
projectIds.push(movieTheater.project.id);
|
|
54
55
|
additionalPropertyNamesOnResource.forEach((name) => {
|
|
55
56
|
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
56
57
|
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
57
|
-
unexpextedprojectIds.push(
|
|
58
|
+
unexpextedprojectIds.push(movieTheater.project.id);
|
|
58
59
|
}
|
|
59
60
|
// tslint:disable-next-line:no-magic-numbers
|
|
60
61
|
if (name.length < 5) {
|
|
61
62
|
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
62
|
-
unexpextedprojectIds.push(
|
|
63
|
+
unexpextedprojectIds.push(movieTheater.project.id);
|
|
63
64
|
}
|
|
64
65
|
});
|
|
65
66
|
|
|
@@ -67,19 +68,19 @@ async function main() {
|
|
|
67
68
|
checked += 1;
|
|
68
69
|
const existingAdditionalProperties = await additionalPropertyRepo.search({
|
|
69
70
|
limit: 1,
|
|
70
|
-
project: { id: { $eq:
|
|
71
|
+
project: { id: { $eq: movieTheater.project.id } },
|
|
71
72
|
codeValue: { $eq: additionalPropertyNameOnResource },
|
|
72
|
-
inCodeSet: { identifier: { $eq:
|
|
73
|
+
inCodeSet: { identifier: { $eq: movieTheater.typeOf } }
|
|
73
74
|
});
|
|
74
75
|
if (existingAdditionalProperties.length === 0) {
|
|
75
76
|
const additionalProperty: chevre.factory.additionalProperty.IAdditionalProperty = {
|
|
76
|
-
project:
|
|
77
|
+
project: movieTheater.project,
|
|
77
78
|
// id?: string;
|
|
78
79
|
typeOf: 'CategoryCode',
|
|
79
80
|
codeValue: additionalPropertyNameOnResource,
|
|
80
81
|
inCodeSet: {
|
|
81
82
|
typeOf: 'CategoryCodeSet',
|
|
82
|
-
identifier:
|
|
83
|
+
identifier: movieTheater.typeOf
|
|
83
84
|
},
|
|
84
85
|
name: { ja: additionalPropertyNameOnResource }
|
|
85
86
|
};
|
|
@@ -88,22 +89,21 @@ async function main() {
|
|
|
88
89
|
console.log(
|
|
89
90
|
'additionalProerty created',
|
|
90
91
|
additionalPropertyNameOnResource,
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
movieTheater.project.id,
|
|
93
|
+
movieTheater.branchCode
|
|
93
94
|
);
|
|
94
95
|
} else {
|
|
95
96
|
console.log(
|
|
96
97
|
'additionalProerty existed',
|
|
97
98
|
additionalPropertyNameOnResource,
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
movieTheater.project.id,
|
|
100
|
+
movieTheater.branchCode
|
|
100
101
|
);
|
|
101
102
|
}
|
|
102
|
-
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
|
-
console.log(i, '
|
|
106
|
+
console.log(i, 'places checked');
|
|
107
107
|
console.log('additionalPropertyNames:', [...new Set(additionalPropertyNames)]);
|
|
108
108
|
console.log('projectIds:', [...new Set(projectIds)]);
|
|
109
109
|
console.log('unexpextedprojectIds:', [...new Set(unexpextedprojectIds)]);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const categoryCodes = await categoryCodeRepo.searchByAggregate(
|
|
14
|
+
{
|
|
15
|
+
limit: 100,
|
|
16
|
+
page: 1,
|
|
17
|
+
sort: { codeValue: chevre.factory.sortType.Ascending }
|
|
18
|
+
// id: { $eq: 'xxx' }
|
|
19
|
+
// project: { id: { $eq: project.id } }
|
|
20
|
+
// paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
|
|
21
|
+
// hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
|
|
22
|
+
},
|
|
23
|
+
['_id'],
|
|
24
|
+
[]
|
|
25
|
+
);
|
|
26
|
+
console.log('categoryCodes found', categoryCodes[0]);
|
|
27
|
+
console.log(categoryCodes.length, 'categoryCodes found');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
main()
|
|
31
|
+
.then()
|
|
32
|
+
.catch(console.error);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
const sellerRepo = await chevre.repository.Seller.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const sellersByAggregate = await sellerRepo.searchByAggregate(
|
|
14
|
+
{
|
|
15
|
+
limit: 5,
|
|
16
|
+
page: 1,
|
|
17
|
+
sort: { branchCode: chevre.factory.sortType.Descending },
|
|
18
|
+
id: { $eq: 'xxx' }
|
|
19
|
+
// project: { id: { $eq: project.id } }
|
|
20
|
+
// paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
|
|
21
|
+
// hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
|
|
22
|
+
},
|
|
23
|
+
[],
|
|
24
|
+
['hasMerchantReturnPolicy', 'additionalProperty', 'project', 'name', 'typeOf', 'url', 'telephone']
|
|
25
|
+
);
|
|
26
|
+
console.log('sellers found', sellersByAggregate, sellersByAggregate[0]?.hasMerchantReturnPolicy);
|
|
27
|
+
console.log(sellersByAggregate.length, 'sellers found');
|
|
28
|
+
|
|
29
|
+
const sellers = await sellerRepo.search(
|
|
30
|
+
{
|
|
31
|
+
limit: 5,
|
|
32
|
+
page: 1,
|
|
33
|
+
sort: { branchCode: chevre.factory.sortType.Descending },
|
|
34
|
+
id: { $eq: 'xxx' }
|
|
35
|
+
// project: { id: { $eq: project.id } }
|
|
36
|
+
// paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
|
|
37
|
+
// hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
|
|
38
|
+
},
|
|
39
|
+
[],
|
|
40
|
+
['hasMerchantReturnPolicy', 'additionalProperty', 'project', 'name', 'typeOf', 'url', 'telephone']
|
|
41
|
+
);
|
|
42
|
+
console.log('sellers found', sellers, sellers[0]?.hasMerchantReturnPolicy);
|
|
43
|
+
console.log(sellers.length, 'sellers found');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
main()
|
|
47
|
+
.then()
|
|
48
|
+
.catch(console.error);
|
|
@@ -1,31 +1,45 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
2
|
import * as mongoose from 'mongoose';
|
|
4
3
|
|
|
5
4
|
import { chevre } from '../../../lib/index';
|
|
6
5
|
|
|
7
|
-
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
6
|
+
// const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
8
7
|
|
|
9
8
|
async function main() {
|
|
10
9
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
10
|
|
|
12
|
-
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
13
|
-
|
|
14
11
|
let updateResult: any;
|
|
15
|
-
|
|
12
|
+
|
|
13
|
+
const sellerRepo = await chevre.repository.Seller.createInstance(mongoose.connection);
|
|
14
|
+
updateResult = await sellerRepo.unsetUnnecessaryFields({
|
|
16
15
|
filter: {
|
|
17
16
|
// 'project.id': { $eq: PROJECT_ID },
|
|
18
|
-
typeOf: { $eq: chevre.factory.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
typeOf: { $eq: chevre.factory.organizationType.Corporation },
|
|
18
|
+
areaServed: { $exists: true }
|
|
19
|
+
},
|
|
20
|
+
$unset: { areaServed: 1 }
|
|
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
|
+
]
|
|
25
36
|
},
|
|
26
|
-
$unset: {
|
|
37
|
+
$unset: {
|
|
38
|
+
'offers.project': 1,
|
|
39
|
+
'offers.priceCurrency': 1
|
|
40
|
+
}
|
|
27
41
|
});
|
|
28
|
-
console.log('unset processed.', updateResult
|
|
42
|
+
console.log('unset processed.', updateResult);
|
|
29
43
|
}
|
|
30
44
|
|
|
31
45
|
main()
|
|
@@ -22,23 +22,27 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import
|
|
25
|
+
import { AnyExpression, Connection, FilterQuery } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
|
+
type IKeyOfProjection = keyof factory.categoryCode.ICategoryCode | '_id';
|
|
27
28
|
/**
|
|
28
29
|
* 区分リポジトリ
|
|
29
30
|
*/
|
|
30
31
|
export declare class MongoRepository {
|
|
31
32
|
private readonly categoryCodeModel;
|
|
32
33
|
constructor(connection: Connection);
|
|
33
|
-
static CREATE_MONGO_CONDITIONS(params: factory.categoryCode.ISearchConditions):
|
|
34
|
-
|
|
34
|
+
static CREATE_MONGO_CONDITIONS(params: factory.categoryCode.ISearchConditions): FilterQuery<factory.categoryCode.ICategoryCode>[];
|
|
35
|
+
static CREATE_AGGREGATE_PROJECTION(inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): {
|
|
36
|
+
[field: string]: AnyExpression;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* 集計検索(publicな属性検索が目的)
|
|
40
|
+
*/
|
|
41
|
+
searchByAggregate(conditions: factory.categoryCode.ISearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<factory.categoryCode.ICategoryCode[]>;
|
|
35
42
|
/**
|
|
36
43
|
* 検索
|
|
37
44
|
*/
|
|
38
|
-
search(params: factory.categoryCode.ISearchConditions, inclusion:
|
|
39
|
-
findById(params: {
|
|
40
|
-
id: string;
|
|
41
|
-
}): Promise<factory.categoryCode.ICategoryCode>;
|
|
45
|
+
search(params: factory.categoryCode.ISearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<factory.categoryCode.ICategoryCode[]>;
|
|
42
46
|
save(params: {
|
|
43
47
|
id?: string;
|
|
44
48
|
attributes: factory.categoryCode.ICategoryCode;
|
|
@@ -61,5 +65,6 @@ export declare class MongoRepository {
|
|
|
61
65
|
id: string;
|
|
62
66
|
};
|
|
63
67
|
}): Promise<void>;
|
|
64
|
-
getCursor(conditions:
|
|
68
|
+
getCursor(conditions: FilterQuery<factory.categoryCode.ICategoryCode>, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
65
69
|
}
|
|
70
|
+
export {};
|
|
@@ -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 categoryCode_1 = require("./mongoose/schemas/categoryCode");
|
|
25
26
|
const factory = require("../factory");
|
|
26
27
|
const settings_1 = require("../settings");
|
|
@@ -34,7 +35,6 @@ class MongoRepository {
|
|
|
34
35
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
35
36
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
36
37
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
37
|
-
// MongoDB検索条件
|
|
38
38
|
const andConditions = [];
|
|
39
39
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
40
40
|
/* istanbul ignore else */
|
|
@@ -51,11 +51,13 @@ class MongoRepository {
|
|
|
51
51
|
}
|
|
52
52
|
const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
|
|
53
53
|
if (typeof idEq === 'string') {
|
|
54
|
-
andConditions.push({ _id: { $eq: idEq } });
|
|
54
|
+
// andConditions.push({ _id: { $eq: idEq } });
|
|
55
|
+
andConditions.push({ _id: { $eq: new mongoose_1.Types.ObjectId(idEq) } });
|
|
55
56
|
}
|
|
56
57
|
const idIn = (_b = params.id) === null || _b === void 0 ? void 0 : _b.$in;
|
|
57
58
|
if (Array.isArray(idIn)) {
|
|
58
|
-
andConditions.push({ _id: { $in: idIn } });
|
|
59
|
+
// andConditions.push({ _id: { $in: idIn } });
|
|
60
|
+
andConditions.push({ _id: { $in: idIn.map((id) => new mongoose_1.Types.ObjectId(id)) } });
|
|
59
61
|
}
|
|
60
62
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
61
63
|
/* istanbul ignore else */
|
|
@@ -149,12 +151,68 @@ class MongoRepository {
|
|
|
149
151
|
}
|
|
150
152
|
return andConditions;
|
|
151
153
|
}
|
|
152
|
-
|
|
154
|
+
static CREATE_AGGREGATE_PROJECTION(inclusion, exclusion) {
|
|
155
|
+
let projectStage = {
|
|
156
|
+
_id: 0,
|
|
157
|
+
id: { $toString: '$_id' },
|
|
158
|
+
project: '$project',
|
|
159
|
+
typeOf: '$typeOf',
|
|
160
|
+
additionalProperty: '$additionalProperty',
|
|
161
|
+
color: '$color',
|
|
162
|
+
image: '$image',
|
|
163
|
+
codeValue: '$codeValue',
|
|
164
|
+
inCodeSet: '$inCodeSet',
|
|
165
|
+
name: '$name',
|
|
166
|
+
paymentMethod: '$paymentMethod'
|
|
167
|
+
};
|
|
168
|
+
if (inclusion.length > 0) {
|
|
169
|
+
projectStage = { _id: 0 };
|
|
170
|
+
inclusion.forEach((field) => {
|
|
171
|
+
switch (field) {
|
|
172
|
+
case '_id':
|
|
173
|
+
case 'id':
|
|
174
|
+
projectStage.id = { $toString: '$_id' };
|
|
175
|
+
break;
|
|
176
|
+
default:
|
|
177
|
+
projectStage[field] = `$${field}`;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
else if (exclusion.length > 0) {
|
|
182
|
+
exclusion.forEach((field) => {
|
|
183
|
+
if (typeof projectStage[field] === 'string' || typeof projectStage[field] === 'object') {
|
|
184
|
+
// tslint:disable-next-line:no-dynamic-delete
|
|
185
|
+
delete projectStage[field];
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return projectStage;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* 集計検索(publicな属性検索が目的)
|
|
193
|
+
*/
|
|
194
|
+
searchByAggregate(conditions, inclusion, exclusion) {
|
|
195
|
+
var _a;
|
|
153
196
|
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
197
|
+
const matchStages = MongoRepository.CREATE_MONGO_CONDITIONS(conditions)
|
|
198
|
+
.map((c) => ({ $match: c }));
|
|
199
|
+
const projectStage = MongoRepository.CREATE_AGGREGATE_PROJECTION(inclusion, exclusion);
|
|
200
|
+
const sortByCodeValue = (_a = conditions.sort) === null || _a === void 0 ? void 0 : _a.codeValue;
|
|
201
|
+
const aggregate = this.categoryCodeModel.aggregate([
|
|
202
|
+
...matchStages,
|
|
203
|
+
...(typeof sortByCodeValue === 'number')
|
|
204
|
+
? [{ $sort: { codeValue: sortByCodeValue } }]
|
|
205
|
+
: [],
|
|
206
|
+
{ $project: projectStage }
|
|
207
|
+
]);
|
|
208
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
209
|
+
/* istanbul ignore else */
|
|
210
|
+
if (typeof conditions.limit === 'number' && conditions.limit > 0) {
|
|
211
|
+
const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
|
|
212
|
+
aggregate.limit(conditions.limit * page)
|
|
213
|
+
.skip(conditions.limit * (page - 1));
|
|
214
|
+
}
|
|
215
|
+
return aggregate.exec();
|
|
158
216
|
});
|
|
159
217
|
}
|
|
160
218
|
/**
|
|
@@ -197,20 +255,6 @@ class MongoRepository {
|
|
|
197
255
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
198
256
|
});
|
|
199
257
|
}
|
|
200
|
-
findById(params) {
|
|
201
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
202
|
-
const doc = yield this.categoryCodeModel.findOne({ _id: params.id }, {
|
|
203
|
-
__v: 0,
|
|
204
|
-
createdAt: 0,
|
|
205
|
-
updatedAt: 0
|
|
206
|
-
})
|
|
207
|
-
.exec();
|
|
208
|
-
if (doc === null) {
|
|
209
|
-
throw new factory.errors.NotFound(this.categoryCodeModel.modelName);
|
|
210
|
-
}
|
|
211
|
-
return doc.toObject();
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
258
|
save(params) {
|
|
215
259
|
return __awaiter(this, void 0, void 0, function* () {
|
|
216
260
|
let doc;
|
|
@@ -23,15 +23,16 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import type { BulkWriteResult } from 'mongodb';
|
|
26
|
-
import
|
|
26
|
+
import { Connection, FilterQuery } from 'mongoose';
|
|
27
27
|
import * as factory from '../factory';
|
|
28
|
+
type IKeyOfProjection = keyof factory.creativeWork.movie.ICreativeWork | '_id';
|
|
28
29
|
/**
|
|
29
30
|
* コンテンツリポジトリ
|
|
30
31
|
*/
|
|
31
32
|
export declare class MongoRepository {
|
|
32
33
|
private readonly creativeWorkModel;
|
|
33
34
|
constructor(connection: Connection);
|
|
34
|
-
static CREATE_MONGO_CONDITIONS(params: factory.creativeWork.movie.ISearchConditions):
|
|
35
|
+
static CREATE_MONGO_CONDITIONS(params: factory.creativeWork.movie.ISearchConditions): FilterQuery<import("@chevre/factory/lib/creativeWork/movie").ICreativeWork>[];
|
|
35
36
|
/**
|
|
36
37
|
* コンテンツを保管する
|
|
37
38
|
*/
|
|
@@ -42,13 +43,10 @@ export declare class MongoRepository {
|
|
|
42
43
|
upsertMoviesByIdentifier(params: {
|
|
43
44
|
attributes: factory.creativeWork.movie.ICreativeWork;
|
|
44
45
|
}[]): Promise<BulkWriteResult | void>;
|
|
45
|
-
findMovieById(params: {
|
|
46
|
-
id: string;
|
|
47
|
-
}): Promise<factory.creativeWork.movie.ICreativeWork>;
|
|
48
46
|
/**
|
|
49
47
|
* コンテンツを検索する
|
|
50
48
|
*/
|
|
51
|
-
searchMovies(params: factory.creativeWork.movie.ISearchConditions, inclusion:
|
|
49
|
+
searchMovies(params: factory.creativeWork.movie.ISearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<factory.creativeWork.movie.ICreativeWork[]>;
|
|
52
50
|
/**
|
|
53
51
|
* コンテンツを削除する
|
|
54
52
|
*/
|
|
@@ -60,9 +58,10 @@ export declare class MongoRepository {
|
|
|
60
58
|
id: string;
|
|
61
59
|
};
|
|
62
60
|
}): Promise<void>;
|
|
63
|
-
getCursor(conditions:
|
|
61
|
+
getCursor(conditions: FilterQuery<factory.creativeWork.movie.ICreativeWork>, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
64
62
|
unsetUnnecessaryFields(params: {
|
|
65
|
-
filter:
|
|
63
|
+
filter: FilterQuery<factory.creativeWork.movie.ICreativeWork>;
|
|
66
64
|
$unset: any;
|
|
67
65
|
}): Promise<import("mongodb").UpdateResult>;
|
|
68
66
|
}
|
|
67
|
+
export {};
|
|
@@ -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 creativeWork_1 = require("./mongoose/schemas/creativeWork");
|
|
25
26
|
const factory = require("../factory");
|
|
26
27
|
const settings_1 = require("../settings");
|
|
@@ -34,111 +35,65 @@ class MongoRepository {
|
|
|
34
35
|
// tslint:disable-next-line:max-func-body-length
|
|
35
36
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
36
37
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
37
|
-
// MongoDB検索条件
|
|
38
38
|
const andConditions = [
|
|
39
|
-
{
|
|
40
|
-
typeOf: factory.creativeWorkType.Movie
|
|
41
|
-
}
|
|
39
|
+
{ typeOf: { $eq: factory.creativeWorkType.Movie } }
|
|
42
40
|
];
|
|
43
41
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
44
42
|
if (typeof projectIdEq === 'string') {
|
|
45
|
-
andConditions.push({
|
|
46
|
-
'project.id': {
|
|
47
|
-
$eq: projectIdEq
|
|
48
|
-
}
|
|
49
|
-
});
|
|
43
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
50
44
|
}
|
|
51
45
|
const contentRatingEq = (_c = params.contentRating) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
52
46
|
if (typeof contentRatingEq === 'string') {
|
|
53
|
-
andConditions.push({
|
|
54
|
-
contentRating: {
|
|
55
|
-
$exists: true,
|
|
56
|
-
$eq: contentRatingEq
|
|
57
|
-
}
|
|
58
|
-
});
|
|
47
|
+
andConditions.push({ contentRating: { $exists: true, $eq: contentRatingEq } });
|
|
59
48
|
}
|
|
60
49
|
const distributorCodeValueEq = (_e = (_d = params.distributor) === null || _d === void 0 ? void 0 : _d.codeValue) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
61
50
|
if (typeof distributorCodeValueEq === 'string') {
|
|
62
|
-
andConditions.push({
|
|
63
|
-
'distributor.codeValue': {
|
|
64
|
-
$exists: true,
|
|
65
|
-
$eq: distributorCodeValueEq
|
|
66
|
-
}
|
|
67
|
-
});
|
|
51
|
+
andConditions.push({ 'distributor.codeValue': { $exists: true, $eq: distributorCodeValueEq } });
|
|
68
52
|
}
|
|
69
53
|
const idEq = (_f = params.id) === null || _f === void 0 ? void 0 : _f.$eq;
|
|
70
54
|
if (typeof idEq === 'string') {
|
|
71
|
-
andConditions.push({ _id: { $eq: idEq } });
|
|
55
|
+
// andConditions.push({ _id: { $eq: idEq } });
|
|
56
|
+
andConditions.push({ _id: { $eq: new mongoose_1.Types.ObjectId(idEq) } });
|
|
72
57
|
}
|
|
73
58
|
const idIn = (_g = params.id) === null || _g === void 0 ? void 0 : _g.$in;
|
|
74
59
|
if (Array.isArray(idIn)) {
|
|
75
|
-
andConditions.push({ _id: { $in: idIn } });
|
|
60
|
+
// andConditions.push({ _id: { $in: idIn } });
|
|
61
|
+
andConditions.push({ _id: { $in: idIn.map((id) => new mongoose_1.Types.ObjectId(id)) } });
|
|
76
62
|
}
|
|
77
63
|
if (typeof params.identifier === 'string') {
|
|
78
64
|
if (params.identifier.length > 0) {
|
|
79
|
-
andConditions.push({
|
|
80
|
-
identifier: { $regex: new RegExp(params.identifier) }
|
|
81
|
-
});
|
|
65
|
+
andConditions.push({ identifier: { $regex: new RegExp(params.identifier) } });
|
|
82
66
|
}
|
|
83
67
|
}
|
|
84
68
|
else {
|
|
85
69
|
const identifierEq = (_h = params.identifier) === null || _h === void 0 ? void 0 : _h.$eq;
|
|
86
70
|
if (typeof identifierEq === 'string') {
|
|
87
|
-
andConditions.push({
|
|
88
|
-
identifier: { $eq: identifierEq }
|
|
89
|
-
});
|
|
71
|
+
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
90
72
|
}
|
|
91
73
|
const identifierIn = (_j = params.identifier) === null || _j === void 0 ? void 0 : _j.$in;
|
|
92
74
|
if (Array.isArray(identifierIn)) {
|
|
93
|
-
andConditions.push({
|
|
94
|
-
identifier: { $in: identifierIn }
|
|
95
|
-
});
|
|
75
|
+
andConditions.push({ identifier: { $in: identifierIn } });
|
|
96
76
|
}
|
|
97
77
|
}
|
|
98
78
|
if (typeof params.name === 'string' && params.name.length > 0) {
|
|
99
79
|
// 多言語名称対応(2022-07-11~)
|
|
100
80
|
andConditions.push({
|
|
101
81
|
$or: [
|
|
102
|
-
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
$regex: new RegExp(params.name)
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
'name.ja': {
|
|
110
|
-
$exists: true,
|
|
111
|
-
$regex: new RegExp(params.name)
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
'name.en': {
|
|
116
|
-
$exists: true,
|
|
117
|
-
$regex: new RegExp(params.name)
|
|
118
|
-
}
|
|
119
|
-
}
|
|
82
|
+
{ name: { $exists: true, $regex: new RegExp(params.name) } },
|
|
83
|
+
{ 'name.ja': { $exists: true, $regex: new RegExp(params.name) } },
|
|
84
|
+
{ 'name.en': { $exists: true, $regex: new RegExp(params.name) } }
|
|
120
85
|
]
|
|
121
86
|
});
|
|
122
87
|
}
|
|
123
88
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
124
89
|
/* istanbul ignore else */
|
|
125
90
|
if (params.datePublishedFrom !== undefined) {
|
|
126
|
-
andConditions.push({
|
|
127
|
-
datePublished: {
|
|
128
|
-
$exists: true,
|
|
129
|
-
$gte: params.datePublishedFrom
|
|
130
|
-
}
|
|
131
|
-
});
|
|
91
|
+
andConditions.push({ datePublished: { $exists: true, $gte: params.datePublishedFrom } });
|
|
132
92
|
}
|
|
133
93
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
134
94
|
/* istanbul ignore else */
|
|
135
95
|
if (params.datePublishedThrough !== undefined) {
|
|
136
|
-
andConditions.push({
|
|
137
|
-
datePublished: {
|
|
138
|
-
$exists: true,
|
|
139
|
-
$lte: params.datePublishedThrough
|
|
140
|
-
}
|
|
141
|
-
});
|
|
96
|
+
andConditions.push({ datePublished: { $exists: true, $lte: params.datePublishedThrough } });
|
|
142
97
|
}
|
|
143
98
|
const offersAvailableFrom = (_k = params.offers) === null || _k === void 0 ? void 0 : _k.availableFrom;
|
|
144
99
|
if (offersAvailableFrom instanceof Date) {
|
|
@@ -171,7 +126,7 @@ class MongoRepository {
|
|
|
171
126
|
else {
|
|
172
127
|
// 上書き禁止属性を除外(2022-08-24~)
|
|
173
128
|
const { id, identifier, project, typeOf } = params, updateFields = __rest(params, ["id", "identifier", "project", "typeOf"]);
|
|
174
|
-
doc = yield this.creativeWorkModel.findOneAndUpdate({ _id: params.id }, updateFields, { upsert: false, new: true })
|
|
129
|
+
doc = yield this.creativeWorkModel.findOneAndUpdate({ _id: { $eq: params.id } }, updateFields, { upsert: false, new: true })
|
|
175
130
|
.exec();
|
|
176
131
|
}
|
|
177
132
|
if (doc === null) {
|
|
@@ -216,20 +171,6 @@ class MongoRepository {
|
|
|
216
171
|
}
|
|
217
172
|
});
|
|
218
173
|
}
|
|
219
|
-
findMovieById(params) {
|
|
220
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
-
const doc = yield this.creativeWorkModel.findOne({ _id: params.id }, {
|
|
222
|
-
__v: 0,
|
|
223
|
-
createdAt: 0,
|
|
224
|
-
updatedAt: 0
|
|
225
|
-
})
|
|
226
|
-
.exec();
|
|
227
|
-
if (doc === null) {
|
|
228
|
-
throw new factory.errors.NotFound(this.creativeWorkModel.modelName);
|
|
229
|
-
}
|
|
230
|
-
return doc.toObject();
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
174
|
/**
|
|
234
175
|
* コンテンツを検索する
|
|
235
176
|
*/
|
|
@@ -276,7 +217,7 @@ class MongoRepository {
|
|
|
276
217
|
*/
|
|
277
218
|
deleteMovie(params) {
|
|
278
219
|
return __awaiter(this, void 0, void 0, function* () {
|
|
279
|
-
yield this.creativeWorkModel.findOneAndRemove({ _id: params.id })
|
|
220
|
+
yield this.creativeWorkModel.findOneAndRemove({ _id: { $eq: params.id } })
|
|
280
221
|
.exec();
|
|
281
222
|
});
|
|
282
223
|
}
|
|
@@ -8,12 +8,12 @@ const modelName = 'Seller';
|
|
|
8
8
|
exports.modelName = modelName;
|
|
9
9
|
const schemaDefinition = {
|
|
10
10
|
additionalProperty: [mongoose_1.SchemaTypes.Mixed],
|
|
11
|
-
areaServed: [
|
|
11
|
+
// areaServed: [SchemaTypes.Mixed],
|
|
12
12
|
branchCode: String,
|
|
13
13
|
hasMerchantReturnPolicy: [mongoose_1.SchemaTypes.Mixed],
|
|
14
14
|
makesOffer: [mongoose_1.SchemaTypes.Mixed],
|
|
15
15
|
name: mongoose_1.SchemaTypes.Mixed,
|
|
16
|
-
parentOrganization:
|
|
16
|
+
// parentOrganization: SchemaTypes.Mixed,
|
|
17
17
|
paymentAccepted: [mongoose_1.SchemaTypes.Mixed],
|
|
18
18
|
project: mongoose_1.SchemaTypes.Mixed,
|
|
19
19
|
typeOf: {
|
|
@@ -22,21 +22,22 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import type { AnyExpression, Connection } from 'mongoose';
|
|
25
|
+
import type { AnyExpression, Connection, FilterQuery } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
27
|
type IScreeningRoomSectionWithoutContainsPlace = Omit<factory.place.screeningRoomSection.IPlace, 'containsPlace'>;
|
|
28
28
|
export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.IPlace, 'typeOf' | 'branchCode' | 'name' | 'containsPlace' | 'seatCount' | 'parentOrganization'>;
|
|
29
29
|
export type IMovieTheaterIncludingScreeningRooms = factory.place.movieTheater.IPlace & {
|
|
30
30
|
containsPlace: factory.place.screeningRoom.IPlace[];
|
|
31
31
|
};
|
|
32
|
+
type IKeyOfProjectionMovieTheater = keyof factory.place.movieTheater.IPlace | '_id';
|
|
32
33
|
/**
|
|
33
34
|
* 施設リポジトリ
|
|
34
35
|
*/
|
|
35
36
|
export declare class MongoRepository {
|
|
36
37
|
private readonly placeModel;
|
|
37
38
|
constructor(connection: Connection);
|
|
38
|
-
static CREATE_BUS_STOP_MONGO_CONDITIONS(params: factory.place.busStop.ISearchConditions):
|
|
39
|
-
static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params: factory.place.movieTheater.ISearchConditions):
|
|
39
|
+
static CREATE_BUS_STOP_MONGO_CONDITIONS(params: factory.place.busStop.ISearchConditions): FilterQuery<import("@chevre/factory/lib/place/busStop").IPlace>[];
|
|
40
|
+
static CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params: factory.place.movieTheater.ISearchConditions): FilterQuery<import("@chevre/factory/lib/place/movieTheater").IPlace>[];
|
|
40
41
|
static CREATE_SEARCH_SEATS_PROJECTION(params: factory.place.seat.IProjection): {
|
|
41
42
|
[field: string]: AnyExpression;
|
|
42
43
|
};
|
|
@@ -48,7 +49,7 @@ export declare class MongoRepository {
|
|
|
48
49
|
/**
|
|
49
50
|
* 施設検索
|
|
50
51
|
*/
|
|
51
|
-
searchMovieTheaters(params: factory.place.movieTheater.ISearchConditions, inclusion:
|
|
52
|
+
searchMovieTheaters(params: factory.place.movieTheater.ISearchConditions, inclusion: IKeyOfProjectionMovieTheater[], exclusion: IKeyOfProjectionMovieTheater[]): Promise<factory.place.movieTheater.IPlace[]>;
|
|
52
53
|
deleteMovieTheaterById(params: {
|
|
53
54
|
project: {
|
|
54
55
|
id: string;
|
|
@@ -283,14 +284,10 @@ export declare class MongoRepository {
|
|
|
283
284
|
};
|
|
284
285
|
typeOf: factory.placeType.ScreeningRoom;
|
|
285
286
|
}>;
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
id: string;
|
|
291
|
-
}): Promise<{
|
|
292
|
-
id: string;
|
|
293
|
-
} | undefined>;
|
|
287
|
+
unsetUnnecessaryFieldsFromMovieTheater(params: {
|
|
288
|
+
filter: FilterQuery<any>;
|
|
289
|
+
$unset: any;
|
|
290
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
294
291
|
deleteManyByParentOrganizationId(params: {
|
|
295
292
|
project: {
|
|
296
293
|
id: string;
|
|
@@ -324,6 +321,6 @@ export declare class MongoRepository {
|
|
|
324
321
|
};
|
|
325
322
|
id: string;
|
|
326
323
|
}): Promise<void>;
|
|
327
|
-
getCursor(conditions: any
|
|
324
|
+
getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
328
325
|
}
|
|
329
326
|
export {};
|
package/lib/chevre/repo/place.js
CHANGED
|
@@ -24,7 +24,6 @@ exports.MongoRepository = void 0;
|
|
|
24
24
|
const place_1 = require("./mongoose/schemas/place");
|
|
25
25
|
const factory = require("../factory");
|
|
26
26
|
const settings_1 = require("../settings");
|
|
27
|
-
// const debug = createDebug('chevre-domain:repo:place');
|
|
28
27
|
/**
|
|
29
28
|
* 施設リポジトリ
|
|
30
29
|
*/
|
|
@@ -210,17 +209,17 @@ class MongoRepository {
|
|
|
210
209
|
return andConditions;
|
|
211
210
|
}
|
|
212
211
|
static CREATE_SEARCH_SEATS_PROJECTION(params) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
212
|
+
const includeSectionBranchCode = params['containedInPlace.branchCode'] !== 0;
|
|
213
|
+
const includeSectionName = params['containedInPlace.name'] !== 0;
|
|
214
|
+
const includeSectionTypeOf = params['containedInPlace.typeOf'] !== 0;
|
|
215
|
+
const includeScreeningRooms = params['containedInPlace.containedInPlace'] !== 0;
|
|
217
216
|
const projectStage = {
|
|
218
217
|
_id: 0,
|
|
219
218
|
typeOf: '$containsPlace.containsPlace.typeOf',
|
|
220
219
|
branchCode: '$containsPlace.containsPlace.branchCode',
|
|
221
220
|
name: '$containsPlace.containsPlace.name',
|
|
222
221
|
seatingType: '$containsPlace.containsPlace.seatingType',
|
|
223
|
-
containedInPlace: Object.assign({
|
|
222
|
+
containedInPlace: Object.assign(Object.assign(Object.assign(Object.assign({}, (includeSectionBranchCode) ? { branchCode: '$containsPlace.branchCode' } : undefined), (includeSectionName) ? { name: '$containsPlace.name' } : undefined), (includeSectionTypeOf) ? { typeOf: '$containsPlace.typeOf' } : undefined), (includeScreeningRooms)
|
|
224
223
|
? {
|
|
225
224
|
containedInPlace: {
|
|
226
225
|
typeOf: '$typeOf',
|
|
@@ -333,9 +332,7 @@ class MongoRepository {
|
|
|
333
332
|
/**
|
|
334
333
|
* 施設検索
|
|
335
334
|
*/
|
|
336
|
-
searchMovieTheaters(params,
|
|
337
|
-
// projection明示指定化(2023-06-22~)
|
|
338
|
-
inclusion, exclusion) {
|
|
335
|
+
searchMovieTheaters(params, inclusion, exclusion) {
|
|
339
336
|
var _a;
|
|
340
337
|
return __awaiter(this, void 0, void 0, function* () {
|
|
341
338
|
const conditions = MongoRepository.CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params);
|
|
@@ -1287,23 +1284,10 @@ class MongoRepository {
|
|
|
1287
1284
|
return doc.toObject();
|
|
1288
1285
|
});
|
|
1289
1286
|
}
|
|
1290
|
-
|
|
1287
|
+
unsetUnnecessaryFieldsFromMovieTheater(params) {
|
|
1291
1288
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1292
|
-
return this.placeModel.
|
|
1293
|
-
|
|
1294
|
-
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
1295
|
-
'containsPlace.branchCode': { $exists: true }
|
|
1296
|
-
}, {
|
|
1297
|
-
$unset: { containsPlace: 1 }
|
|
1298
|
-
})
|
|
1299
|
-
.select({ _id: 1 })
|
|
1300
|
-
.exec()
|
|
1301
|
-
.then((doc) => {
|
|
1302
|
-
if (doc === null) {
|
|
1303
|
-
return;
|
|
1304
|
-
}
|
|
1305
|
-
return doc.toObject();
|
|
1306
|
-
});
|
|
1289
|
+
return this.placeModel.updateMany(params.filter, { $unset: params.$unset })
|
|
1290
|
+
.exec();
|
|
1307
1291
|
});
|
|
1308
1292
|
}
|
|
1309
1293
|
deleteManyByParentOrganizationId(params) {
|
|
@@ -22,9 +22,10 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import { Connection } from 'mongoose';
|
|
25
|
+
import { AnyExpression, Connection, FilterQuery } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
27
|
export type ISeller = factory.seller.ISeller;
|
|
28
|
+
export type ISellerByAggregate = Pick<ISeller, 'additionalProperty' | 'branchCode' | 'hasMerchantReturnPolicy' | 'id' | 'name' | 'project' | 'telephone' | 'typeOf' | 'url'>;
|
|
28
29
|
export interface IMemberSearchConditions {
|
|
29
30
|
/**
|
|
30
31
|
* 販売者メンバーで絞る場合
|
|
@@ -37,17 +38,17 @@ export interface IMemberSearchConditions {
|
|
|
37
38
|
};
|
|
38
39
|
};
|
|
39
40
|
}
|
|
41
|
+
type IKeyOfProjection = keyof ISeller | '_id';
|
|
40
42
|
/**
|
|
41
43
|
* 販売者リポジトリ
|
|
42
44
|
*/
|
|
43
45
|
export declare class MongoRepository {
|
|
44
46
|
private readonly organizationModel;
|
|
45
47
|
constructor(connection: Connection);
|
|
46
|
-
static CREATE_MONGO_CONDITIONS(params: factory.seller.ISearchConditions & IMemberSearchConditions):
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*/
|
|
48
|
+
static CREATE_MONGO_CONDITIONS(params: factory.seller.ISearchConditions & IMemberSearchConditions): FilterQuery<factory.seller.ISeller>[];
|
|
49
|
+
static CREATE_AGGREGATE_SELLERS_PROJECTION(inclusion: string[], exclusion: (keyof ISellerByAggregate)[]): {
|
|
50
|
+
[field: string]: AnyExpression;
|
|
51
|
+
};
|
|
51
52
|
/**
|
|
52
53
|
* 販売者を保管する
|
|
53
54
|
*/
|
|
@@ -55,10 +56,14 @@ export declare class MongoRepository {
|
|
|
55
56
|
id?: string;
|
|
56
57
|
attributes: factory.seller.ISeller;
|
|
57
58
|
}): Promise<ISeller>;
|
|
59
|
+
/**
|
|
60
|
+
* 集計検索(publicな属性検索が目的)
|
|
61
|
+
*/
|
|
62
|
+
searchByAggregate(conditions: factory.seller.ISearchConditions & IMemberSearchConditions, inclusion: (keyof ISellerByAggregate)[], exclusion: (keyof ISellerByAggregate)[]): Promise<ISellerByAggregate[]>;
|
|
58
63
|
/**
|
|
59
64
|
* 販売者検索
|
|
60
65
|
*/
|
|
61
|
-
search(conditions: factory.seller.ISearchConditions & IMemberSearchConditions, inclusion:
|
|
66
|
+
search(conditions: factory.seller.ISearchConditions & IMemberSearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<ISeller[]>;
|
|
62
67
|
/**
|
|
63
68
|
* 対応決済方法を検索する
|
|
64
69
|
*/
|
|
@@ -96,5 +101,10 @@ export declare class MongoRepository {
|
|
|
96
101
|
id: string;
|
|
97
102
|
};
|
|
98
103
|
}): Promise<void>;
|
|
99
|
-
getCursor(conditions:
|
|
104
|
+
getCursor(conditions: FilterQuery<factory.seller.ISeller>, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
105
|
+
unsetUnnecessaryFields(params: {
|
|
106
|
+
filter: any;
|
|
107
|
+
$unset: any;
|
|
108
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
100
109
|
}
|
|
110
|
+
export {};
|
|
@@ -35,7 +35,6 @@ class MongoRepository {
|
|
|
35
35
|
// tslint:disable-next-line:max-func-body-length
|
|
36
36
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
37
37
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
38
|
-
// MongoDB検索条件
|
|
39
38
|
const andConditions = [];
|
|
40
39
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
41
40
|
if (typeof projectIdEq === 'string') {
|
|
@@ -43,12 +42,14 @@ class MongoRepository {
|
|
|
43
42
|
}
|
|
44
43
|
const idEq = (_c = params.id) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
45
44
|
if (typeof idEq === 'string') {
|
|
46
|
-
andConditions.push({ _id: { $eq: idEq } });
|
|
45
|
+
// andConditions.push({ _id: { $eq: idEq } });
|
|
46
|
+
andConditions.push({ _id: { $eq: new mongoose_1.Types.ObjectId(idEq) } });
|
|
47
47
|
}
|
|
48
48
|
// メンバー条件追加(2023-07-24~)
|
|
49
49
|
const memberMemberOfIdIn = (_f = (_e = (_d = params.member) === null || _d === void 0 ? void 0 : _d.memberOf) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$in;
|
|
50
50
|
if (Array.isArray(memberMemberOfIdIn)) {
|
|
51
|
-
andConditions.push({ _id: { $in: memberMemberOfIdIn } });
|
|
51
|
+
// andConditions.push({ _id: { $in: memberMemberOfIdIn } });
|
|
52
|
+
andConditions.push({ _id: { $in: memberMemberOfIdIn.map((memberMemberOfId) => new mongoose_1.Types.ObjectId(memberMemberOfId)) } });
|
|
52
53
|
}
|
|
53
54
|
const nameRegex = params.name;
|
|
54
55
|
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
@@ -143,41 +144,47 @@ class MongoRepository {
|
|
|
143
144
|
}
|
|
144
145
|
return andConditions;
|
|
145
146
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
147
|
+
static CREATE_AGGREGATE_SELLERS_PROJECTION(inclusion, exclusion) {
|
|
148
|
+
const projectStage = {
|
|
149
|
+
_id: 0,
|
|
150
|
+
id: { $toString: '$_id' },
|
|
151
|
+
additionalProperty: '$additionalProperty',
|
|
152
|
+
branchCode: '$branchCode',
|
|
153
|
+
hasMerchantReturnPolicy: {
|
|
154
|
+
$cond: {
|
|
155
|
+
if: { $isArray: '$hasMerchantReturnPolicy' },
|
|
156
|
+
then: {
|
|
157
|
+
$cond: {
|
|
158
|
+
if: { $eq: [{ $size: '$hasMerchantReturnPolicy' }, 0] },
|
|
159
|
+
then: [],
|
|
160
|
+
else: [{
|
|
161
|
+
url: { $first: '$hasMerchantReturnPolicy.url' },
|
|
162
|
+
typeOf: { $first: '$hasMerchantReturnPolicy.typeOf' }
|
|
163
|
+
}]
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
else: []
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
name: '$name',
|
|
170
|
+
project: '$project',
|
|
171
|
+
typeOf: '$typeOf',
|
|
172
|
+
url: '$url',
|
|
173
|
+
telephone: '$telephone'
|
|
174
|
+
};
|
|
175
|
+
if (inclusion.length > 0) {
|
|
176
|
+
// no op
|
|
177
|
+
}
|
|
178
|
+
else if (exclusion.length > 0) {
|
|
179
|
+
exclusion.forEach((field) => {
|
|
180
|
+
if (typeof projectStage[field] === 'string' || typeof projectStage[field] === 'object') {
|
|
181
|
+
// tslint:disable-next-line:no-dynamic-delete
|
|
182
|
+
delete projectStage[field];
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
return projectStage;
|
|
187
|
+
}
|
|
181
188
|
/**
|
|
182
189
|
* 販売者を保管する
|
|
183
190
|
*/
|
|
@@ -204,6 +211,33 @@ class MongoRepository {
|
|
|
204
211
|
return organization;
|
|
205
212
|
});
|
|
206
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* 集計検索(publicな属性検索が目的)
|
|
216
|
+
*/
|
|
217
|
+
searchByAggregate(conditions, inclusion, exclusion) {
|
|
218
|
+
var _a;
|
|
219
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
220
|
+
const matchStages = MongoRepository.CREATE_MONGO_CONDITIONS(conditions)
|
|
221
|
+
.map((c) => ({ $match: c }));
|
|
222
|
+
const projectStage = MongoRepository.CREATE_AGGREGATE_SELLERS_PROJECTION(inclusion, exclusion);
|
|
223
|
+
const sortByBranchCode = (_a = conditions.sort) === null || _a === void 0 ? void 0 : _a.branchCode;
|
|
224
|
+
const aggregate = this.organizationModel.aggregate([
|
|
225
|
+
...matchStages,
|
|
226
|
+
...(typeof sortByBranchCode === 'number')
|
|
227
|
+
? [{ $sort: { branchCode: sortByBranchCode } }]
|
|
228
|
+
: [],
|
|
229
|
+
{ $project: projectStage }
|
|
230
|
+
]);
|
|
231
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
232
|
+
/* istanbul ignore else */
|
|
233
|
+
if (typeof conditions.limit === 'number' && conditions.limit > 0) {
|
|
234
|
+
const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
|
|
235
|
+
aggregate.limit(conditions.limit * page)
|
|
236
|
+
.skip(conditions.limit * (page - 1));
|
|
237
|
+
}
|
|
238
|
+
return aggregate.exec();
|
|
239
|
+
});
|
|
240
|
+
}
|
|
207
241
|
/**
|
|
208
242
|
* 販売者検索
|
|
209
243
|
*/
|
|
@@ -309,5 +343,11 @@ class MongoRepository {
|
|
|
309
343
|
.sort({ branchCode: factory.sortType.Ascending })
|
|
310
344
|
.cursor();
|
|
311
345
|
}
|
|
346
|
+
unsetUnnecessaryFields(params) {
|
|
347
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
348
|
+
return this.organizationModel.updateMany(params.filter, { $unset: params.$unset })
|
|
349
|
+
.exec();
|
|
350
|
+
});
|
|
351
|
+
}
|
|
312
352
|
}
|
|
313
353
|
exports.MongoRepository = MongoRepository;
|
|
@@ -17,7 +17,7 @@ function createPrice(params) {
|
|
|
17
17
|
name: priceSpec.name,
|
|
18
18
|
price: priceSpec.price,
|
|
19
19
|
priceCurrency: priceSpec.priceCurrency,
|
|
20
|
-
project: priceSpec.project,
|
|
20
|
+
// project: priceSpec.project,
|
|
21
21
|
typeOf: priceSpec.typeOf,
|
|
22
22
|
appliesToCategoryCode: priceSpec.appliesToCategoryCode,
|
|
23
23
|
valueAddedTaxIncluded: priceSpec.valueAddedTaxIncluded
|
|
@@ -697,8 +697,8 @@ function createMovieTheaterFromCOA(project, seller, theaterFromCOA, screensFromC
|
|
|
697
697
|
typeOf: factory.placeType.MovieTheater,
|
|
698
698
|
telephone: theaterFromCOA.theaterTelNum,
|
|
699
699
|
offers: {
|
|
700
|
-
project: { typeOf: project.typeOf, id: project.id },
|
|
701
|
-
priceCurrency: factory.priceCurrency.JPY,
|
|
700
|
+
// project: { typeOf: project.typeOf, id: project.id }, // optimize(2023-11-06~)
|
|
701
|
+
// priceCurrency: factory.priceCurrency.JPY, // optimize(2023-11-06~)
|
|
702
702
|
typeOf: factory.offerType.Offer,
|
|
703
703
|
eligibleQuantity: {
|
|
704
704
|
typeOf: 'QuantitativeValue',
|
|
@@ -9,6 +9,7 @@ import * as EventOfferService from './offer/event';
|
|
|
9
9
|
import * as EventServiceByCOAOfferService from './offer/eventServiceByCOA';
|
|
10
10
|
import * as MoneyTransferOfferService from './offer/moneyTransfer';
|
|
11
11
|
import * as ProductOfferService from './offer/product';
|
|
12
|
+
type ICategoryCodeChargeSpecification = factory.priceSpecification.IPriceSpecification<factory.priceSpecificationType.CategoryCodeChargeSpecification>;
|
|
12
13
|
export { EventOfferService as event, EventServiceByCOAOfferService as eventServiceByCOA, MoneyTransferOfferService as moneyTransfer, ProductOfferService as product };
|
|
13
14
|
/**
|
|
14
15
|
* 座席にオファー情報を付加する
|
|
@@ -19,7 +20,7 @@ export declare function addOffers2Seat(params: {
|
|
|
19
20
|
/**
|
|
20
21
|
* 座席区分加算料金
|
|
21
22
|
*/
|
|
22
|
-
priceSpecs:
|
|
23
|
+
priceSpecs: ICategoryCodeChargeSpecification[];
|
|
23
24
|
}): factory.place.seat.IPlaceWithOffer;
|
|
24
25
|
/**
|
|
25
26
|
* イベントに対する座席オファーを検索する
|
|
@@ -30,13 +30,19 @@ function addOffers2Seat(params) {
|
|
|
30
30
|
const seatingTypes = (Array.isArray(params.seat.seatingType))
|
|
31
31
|
? params.seat.seatingType
|
|
32
32
|
: (typeof params.seat.seatingType === 'string' && params.seat.seatingType.length > 0) ? [params.seat.seatingType] : [];
|
|
33
|
-
const priceComponent = params.priceSpecs.filter((
|
|
33
|
+
const priceComponent = params.priceSpecs.filter((priceSpec) => {
|
|
34
34
|
// 適用カテゴリーコードに座席タイプが含まれる価格仕様を検索
|
|
35
|
-
return (Array.isArray(
|
|
36
|
-
&&
|
|
35
|
+
return (Array.isArray(priceSpec.appliesToCategoryCode))
|
|
36
|
+
&& priceSpec.appliesToCategoryCode.some((categoryCode) => {
|
|
37
37
|
return seatingTypes.includes(categoryCode.codeValue);
|
|
38
|
-
// && categoryCode.inCodeSet.identifier === factory.categoryCode.CategorySetIdentifier.SeatingType;
|
|
39
38
|
});
|
|
39
|
+
})
|
|
40
|
+
.map(({ appliesToCategoryCode, name, price, priceCurrency, typeOf, valueAddedTaxIncluded }) => {
|
|
41
|
+
return {
|
|
42
|
+
appliesToCategoryCode,
|
|
43
|
+
// id,
|
|
44
|
+
name, price, priceCurrency, typeOf, valueAddedTaxIncluded
|
|
45
|
+
};
|
|
40
46
|
});
|
|
41
47
|
const priceSpecification = {
|
|
42
48
|
typeOf: factory.priceSpecificationType.CompoundPriceSpecification,
|
|
@@ -46,11 +52,11 @@ function addOffers2Seat(params) {
|
|
|
46
52
|
if (typeof params.availability === 'string') {
|
|
47
53
|
availability = params.availability;
|
|
48
54
|
}
|
|
49
|
-
return Object.assign(Object.assign({}, params.seat), { offers: [{
|
|
50
|
-
typeOf: factory.offerType.Offer,
|
|
51
|
-
availability,
|
|
52
|
-
priceSpecification
|
|
53
|
-
|
|
55
|
+
return Object.assign(Object.assign({}, params.seat), { offers: [Object.assign({
|
|
56
|
+
// typeOf: factory.offerType.Offer, // optimize(2023-11-08~)
|
|
57
|
+
availability }, (priceSpecification.priceComponent.length > 0)
|
|
58
|
+
? { priceSpecification } // priceComponentの存在する場合のみ追加(2023-11-08~)
|
|
59
|
+
: undefined)] });
|
|
54
60
|
}
|
|
55
61
|
exports.addOffers2Seat = addOffers2Seat;
|
|
56
62
|
/**
|
package/package.json
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.
|
|
14
|
-
"@cinerino/sdk": "5.0.0-alpha.
|
|
13
|
+
"@chevre/factory": "4.340.0",
|
|
14
|
+
"@cinerino/sdk": "5.0.0-alpha.11",
|
|
15
15
|
"@motionpicture/coa-service": "9.2.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.2.0",
|
|
17
17
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.15.0-alpha.
|
|
120
|
+
"version": "21.15.0-alpha.10"
|
|
121
121
|
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
// import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../lib/index';
|
|
6
|
-
|
|
7
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
// const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
-
|
|
10
|
-
// tslint:disable-next-line:max-func-body-length
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
-
|
|
14
|
-
const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = memberRepo.getCursor(
|
|
17
|
-
{},
|
|
18
|
-
{
|
|
19
|
-
// _id: 1,
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
console.log('members found');
|
|
23
|
-
|
|
24
|
-
let i = 0;
|
|
25
|
-
let updateCount = 0;
|
|
26
|
-
await cursor.eachAsync(async (doc) => {
|
|
27
|
-
i += 1;
|
|
28
|
-
const iamMember: chevre.factory.iam.IMember = doc.toObject();
|
|
29
|
-
|
|
30
|
-
const memberOfId = iamMember.member.memberOf?.id;
|
|
31
|
-
const alreadyMigrated = typeof memberOfId === 'string';
|
|
32
|
-
|
|
33
|
-
if (alreadyMigrated) {
|
|
34
|
-
console.log('already exist...', iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, memberOfId, i);
|
|
35
|
-
} else {
|
|
36
|
-
console.log(
|
|
37
|
-
'updating reservation...', iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, memberOfId, i);
|
|
38
|
-
await memberRepo.updateByMemberMemberOf({
|
|
39
|
-
project: { id: iamMember.project.id },
|
|
40
|
-
member: {
|
|
41
|
-
id: iamMember.member.id,
|
|
42
|
-
memberOf: {
|
|
43
|
-
id: iamMember.project.id,
|
|
44
|
-
typeOf: chevre.factory.organizationType.Project
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
updateCount += 1;
|
|
49
|
-
console.log('updated.', iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, memberOfId, i);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
console.log(i, 'members checked');
|
|
54
|
-
console.log(updateCount, 'members updated');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
main()
|
|
58
|
-
.then()
|
|
59
|
-
.catch(console.error);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
-
|
|
11
|
-
const sellerRepo = await chevre.repository.Seller.createInstance(mongoose.connection);
|
|
12
|
-
|
|
13
|
-
const sellers = await sellerRepo.search(
|
|
14
|
-
{
|
|
15
|
-
project: { id: { $eq: project.id } },
|
|
16
|
-
paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
|
|
17
|
-
hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
|
|
18
|
-
},
|
|
19
|
-
['name'],
|
|
20
|
-
[]
|
|
21
|
-
);
|
|
22
|
-
console.log('sellers found', sellers);
|
|
23
|
-
console.log(sellers.length, 'sellers found');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
main()
|
|
27
|
-
.then()
|
|
28
|
-
.catch(console.error);
|