@chevre/domain 21.28.0-alpha.9 → 21.29.0-alpha.0
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/playAroundProductModel.ts +64 -0
- package/example/src/chevre/searchCustomerTypes.ts +57 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +14 -10
- package/lib/chevre/repo/aggregateOffer.d.ts +5 -1
- package/lib/chevre/repo/aggregateOffer.js +6 -0
- package/lib/chevre/repo/categoryCode.d.ts +6 -1
- package/lib/chevre/repo/categoryCode.js +6 -15
- package/lib/chevre/repo/customerType.d.ts +22 -0
- package/lib/chevre/repo/customerType.js +105 -0
- package/lib/chevre/repo/mongoose/schemas/customerType.d.ts +5 -0
- package/lib/chevre/repo/mongoose/schemas/customerType.js +66 -0
- package/lib/chevre/repo/mongoose/schemas/order.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/product.js +22 -38
- package/lib/chevre/repo/mongoose/schemas/productModel.d.ts +5 -0
- package/lib/chevre/repo/mongoose/schemas/productModel.js +68 -0
- package/lib/chevre/repo/order.d.ts +2 -4
- package/lib/chevre/repo/order.js +37 -37
- package/lib/chevre/repo/paymentService.d.ts +0 -3
- package/lib/chevre/repo/paymentService.js +1 -45
- package/lib/chevre/repo/product.d.ts +4 -0
- package/lib/chevre/repo/product.js +6 -0
- package/lib/chevre/repo/productModel.d.ts +61 -0
- package/lib/chevre/repo/productModel.js +138 -0
- package/lib/chevre/repository.d.ts +10 -0
- package/lib/chevre/repository.js +28 -2
- package/lib/chevre/service/assetTransaction/pay.js +6 -1
- package/lib/chevre/service/offer/event/authorize.js +18 -1
- package/lib/chevre/service/order/onOrderUpdated/factory.d.ts +1 -1
- package/package.json +3 -3
- package/example/src/chevre/deleteOldPaymentServices.ts +0 -18
- package/example/src/chevre/migratePaymentServicesToNewCollection.ts +0 -21
- package/example/src/chevre/playAroundProjectMakesOffer.ts +0 -47
|
@@ -0,0 +1,64 @@
|
|
|
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, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const productModelRepo = await chevre.repository.ProductModel.createInstance(mongoose.connection);
|
|
12
|
+
const result = await productModelRepo.search(
|
|
13
|
+
{
|
|
14
|
+
limit: 100,
|
|
15
|
+
page: 1,
|
|
16
|
+
category: {
|
|
17
|
+
codeValue: { $in: ['Premium'] },
|
|
18
|
+
inCodeSet: { identifier: { $eq: chevre.factory.categoryCode.CategorySetIdentifier.SeatingType } }
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
[],
|
|
22
|
+
[]
|
|
23
|
+
);
|
|
24
|
+
console.log('result:', result);
|
|
25
|
+
|
|
26
|
+
const productModel = {
|
|
27
|
+
project: {
|
|
28
|
+
id: project.id,
|
|
29
|
+
typeOf: <chevre.factory.organizationType.Project>chevre.factory.organizationType.Project
|
|
30
|
+
},
|
|
31
|
+
typeOf: <'ProductModel'>'ProductModel',
|
|
32
|
+
category: {
|
|
33
|
+
codeValue: 'Premium',
|
|
34
|
+
inCodeSet: {
|
|
35
|
+
identifier: chevre.factory.categoryCode.CategorySetIdentifier.SeatingType,
|
|
36
|
+
typeOf: <'CategoryCodeSet'>'CategoryCodeSet'
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
name: { ja: 'プレミアムシート' },
|
|
40
|
+
offers: [{
|
|
41
|
+
typeOf: <chevre.factory.offerType.Offer>chevre.factory.offerType.Offer
|
|
42
|
+
}]
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const createdModel = await productModelRepo.save({
|
|
46
|
+
$set: productModel
|
|
47
|
+
});
|
|
48
|
+
console.log('created. id:', createdModel);
|
|
49
|
+
|
|
50
|
+
await productModelRepo.save({
|
|
51
|
+
id: createdModel.id,
|
|
52
|
+
$set: productModel
|
|
53
|
+
});
|
|
54
|
+
console.log('updated. id:', createdModel.id);
|
|
55
|
+
|
|
56
|
+
await productModelRepo.deleteById({
|
|
57
|
+
id: createdModel.id
|
|
58
|
+
});
|
|
59
|
+
console.log('deleted. id:', createdModel.id);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
main()
|
|
63
|
+
.then(console.log)
|
|
64
|
+
.catch(console.error);
|
|
@@ -0,0 +1,57 @@
|
|
|
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 customerTypeRepo = await chevre.repository.CustomerType.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const saveResult = await customerTypeRepo.saveManyByCodeValue([
|
|
14
|
+
{
|
|
15
|
+
attributes: {
|
|
16
|
+
typeOf: 'CategoryCode',
|
|
17
|
+
codeValue: 'Enduser',
|
|
18
|
+
name: { ja: 'エンドユーザー' }
|
|
19
|
+
},
|
|
20
|
+
upsert: true
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
attributes: {
|
|
24
|
+
typeOf: 'CategoryCode',
|
|
25
|
+
codeValue: 'POS',
|
|
26
|
+
name: { ja: 'POS' }
|
|
27
|
+
},
|
|
28
|
+
upsert: true
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
attributes: {
|
|
32
|
+
typeOf: 'CategoryCode',
|
|
33
|
+
codeValue: 'TVM',
|
|
34
|
+
name: { ja: '券売機' }
|
|
35
|
+
},
|
|
36
|
+
upsert: true
|
|
37
|
+
}
|
|
38
|
+
]);
|
|
39
|
+
console.log('saved,', saveResult);
|
|
40
|
+
|
|
41
|
+
const categoryCodes = await customerTypeRepo.search(
|
|
42
|
+
{
|
|
43
|
+
limit: 100,
|
|
44
|
+
page: 1,
|
|
45
|
+
sort: { codeValue: chevre.factory.sortType.Ascending },
|
|
46
|
+
codeValue: { $eq: 'Enduser' }
|
|
47
|
+
},
|
|
48
|
+
[],
|
|
49
|
+
[]
|
|
50
|
+
);
|
|
51
|
+
console.log('categoryCodes found', categoryCodes);
|
|
52
|
+
console.log(categoryCodes.length, 'categoryCodes found');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
main()
|
|
56
|
+
.then()
|
|
57
|
+
.catch(console.error);
|
|
@@ -8,18 +8,22 @@ async function main() {
|
|
|
8
8
|
|
|
9
9
|
let updateResult: any;
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
updateResult = await
|
|
11
|
+
const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
|
|
12
|
+
updateResult = await productRepo.unsetUnnecessaryFields({
|
|
13
13
|
filter: {
|
|
14
|
-
|
|
15
|
-
$in: [
|
|
16
|
-
chevre.factory.eventType.ScreeningEvent
|
|
17
|
-
]
|
|
18
|
-
}
|
|
14
|
+
'serviceType.project': { $exists: true }
|
|
19
15
|
},
|
|
20
|
-
$unset:
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
$unset: {
|
|
17
|
+
'serviceType.project': 1
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
console.log('unset processed.', updateResult);
|
|
21
|
+
updateResult = await productRepo.unsetUnnecessaryFields({
|
|
22
|
+
filter: {
|
|
23
|
+
provider: { $exists: true }
|
|
24
|
+
},
|
|
25
|
+
$unset: {
|
|
26
|
+
provider: 1
|
|
23
27
|
}
|
|
24
28
|
});
|
|
25
29
|
console.log('unset processed.', updateResult);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyExpression, Connection, PipelineStage } from 'mongoose';
|
|
1
|
+
import type { AnyExpression, Connection, FilterQuery, PipelineStage } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
3
|
type IMatchStage = PipelineStage.Match;
|
|
4
4
|
type KeyOfUnitPriceOffer = keyof factory.unitPriceOffer.IUnitPriceOffer;
|
|
@@ -69,5 +69,9 @@ export declare class MongoRepository {
|
|
|
69
69
|
* 単価オファー最適化作業における一時的な処理
|
|
70
70
|
*/
|
|
71
71
|
optimizeOffers(): Promise<import("mongodb").UpdateResult>;
|
|
72
|
+
unsetUnnecessaryFields(params: {
|
|
73
|
+
filter: FilterQuery<factory.aggregateOffer.IAggregateOffer>;
|
|
74
|
+
$unset: any;
|
|
75
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
72
76
|
}
|
|
73
77
|
export {};
|
|
@@ -588,5 +588,11 @@ class MongoRepository {
|
|
|
588
588
|
.exec();
|
|
589
589
|
});
|
|
590
590
|
}
|
|
591
|
+
unsetUnnecessaryFields(params) {
|
|
592
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
593
|
+
return this.aggregateOfferModel.updateMany(params.filter, { $unset: params.$unset })
|
|
594
|
+
.exec();
|
|
595
|
+
});
|
|
596
|
+
}
|
|
591
597
|
}
|
|
592
598
|
exports.MongoRepository = MongoRepository;
|
|
@@ -25,6 +25,9 @@
|
|
|
25
25
|
import { AnyExpression, Connection, FilterQuery } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
27
|
type IKeyOfProjection = keyof factory.categoryCode.ICategoryCode | '_id';
|
|
28
|
+
type IUnset = {
|
|
29
|
+
[key in keyof Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'color' | 'image' | 'paymentMethod'>]?: 1;
|
|
30
|
+
};
|
|
28
31
|
/**
|
|
29
32
|
* 区分リポジトリ
|
|
30
33
|
*/
|
|
@@ -45,7 +48,9 @@ export declare class MongoRepository {
|
|
|
45
48
|
search(params: factory.categoryCode.ISearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<factory.categoryCode.ICategoryCode[]>;
|
|
46
49
|
save(params: {
|
|
47
50
|
id?: string;
|
|
48
|
-
attributes: factory.categoryCode.ICategoryCode
|
|
51
|
+
attributes: factory.categoryCode.ICategoryCode & {
|
|
52
|
+
$unset?: IUnset;
|
|
53
|
+
};
|
|
49
54
|
}): Promise<factory.categoryCode.ICategoryCode>;
|
|
50
55
|
saveManyByCodeValue(params: {
|
|
51
56
|
attributes: factory.categoryCode.ICategoryCode;
|
|
@@ -83,21 +83,11 @@ class MongoRepository {
|
|
|
83
83
|
}
|
|
84
84
|
const codeValueEq = (_c = params.codeValue) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
85
85
|
if (typeof codeValueEq === 'string') {
|
|
86
|
-
andConditions.push({
|
|
87
|
-
codeValue: {
|
|
88
|
-
$exists: true,
|
|
89
|
-
$eq: codeValueEq
|
|
90
|
-
}
|
|
91
|
-
});
|
|
86
|
+
andConditions.push({ codeValue: { $eq: codeValueEq } });
|
|
92
87
|
}
|
|
93
88
|
const codeValueIn = (_d = params.codeValue) === null || _d === void 0 ? void 0 : _d.$in;
|
|
94
89
|
if (Array.isArray(codeValueIn)) {
|
|
95
|
-
andConditions.push({
|
|
96
|
-
codeValue: {
|
|
97
|
-
$exists: true,
|
|
98
|
-
$in: codeValueIn
|
|
99
|
-
}
|
|
100
|
-
});
|
|
90
|
+
andConditions.push({ codeValue: { $in: codeValueIn } });
|
|
101
91
|
}
|
|
102
92
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
103
93
|
/* istanbul ignore else */
|
|
@@ -259,12 +249,13 @@ class MongoRepository {
|
|
|
259
249
|
return __awaiter(this, void 0, void 0, function* () {
|
|
260
250
|
let doc;
|
|
261
251
|
if (typeof params.id !== 'string') {
|
|
262
|
-
|
|
252
|
+
const _a = params.attributes, { id, $unset } = _a, creatingDoc = __rest(_a, ["id", "$unset"]);
|
|
253
|
+
doc = yield this.categoryCodeModel.create(creatingDoc);
|
|
263
254
|
}
|
|
264
255
|
else {
|
|
265
256
|
// 上書き禁止属性を除外(2022-08-24~)
|
|
266
|
-
const
|
|
267
|
-
doc = yield this.categoryCodeModel.findOneAndUpdate({ _id: params.id }, updateFields, { upsert: false, new: true })
|
|
257
|
+
const _b = params.attributes, { id, codeValue, inCodeSet, project, typeOf, $unset } = _b, updateFields = __rest(_b, ["id", "codeValue", "inCodeSet", "project", "typeOf", "$unset"]);
|
|
258
|
+
doc = yield this.categoryCodeModel.findOneAndUpdate({ _id: { $eq: params.id } }, Object.assign({ $set: updateFields }, ($unset !== undefined) ? { $unset } : undefined), { upsert: false, new: true })
|
|
268
259
|
.exec();
|
|
269
260
|
}
|
|
270
261
|
if (doc === null) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BulkWriteResult } from 'mongodb';
|
|
2
|
+
import { Connection, FilterQuery } from 'mongoose';
|
|
3
|
+
import * as factory from '../factory';
|
|
4
|
+
type ICustomerType = Pick<factory.categoryCode.ICategoryCode, 'codeValue' | 'id' | 'name' | 'typeOf'>;
|
|
5
|
+
type IKeyOfProjection = keyof ICustomerType | '_id';
|
|
6
|
+
/**
|
|
7
|
+
* カスタマータイプリポジトリ
|
|
8
|
+
*/
|
|
9
|
+
export declare class MongoRepository {
|
|
10
|
+
private readonly customerTypeModel;
|
|
11
|
+
constructor(connection: Connection);
|
|
12
|
+
static CREATE_MONGO_CONDITIONS(params: factory.categoryCode.ISearchConditions): FilterQuery<ICustomerType>[];
|
|
13
|
+
/**
|
|
14
|
+
* 検索
|
|
15
|
+
*/
|
|
16
|
+
search(params: factory.categoryCode.ISearchConditions, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<ICustomerType[]>;
|
|
17
|
+
saveManyByCodeValue(params: {
|
|
18
|
+
attributes: ICustomerType;
|
|
19
|
+
upsert?: boolean;
|
|
20
|
+
}[]): Promise<BulkWriteResult | void>;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MongoRepository = void 0;
|
|
13
|
+
const customerType_1 = require("./mongoose/schemas/customerType");
|
|
14
|
+
const settings_1 = require("../settings");
|
|
15
|
+
/**
|
|
16
|
+
* カスタマータイプリポジトリ
|
|
17
|
+
*/
|
|
18
|
+
class MongoRepository {
|
|
19
|
+
constructor(connection) {
|
|
20
|
+
this.customerTypeModel = connection.model(customerType_1.modelName, (0, customerType_1.createSchema)());
|
|
21
|
+
}
|
|
22
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
23
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const andConditions = [];
|
|
26
|
+
const codeValueEq = (_a = params.codeValue) === null || _a === void 0 ? void 0 : _a.$eq;
|
|
27
|
+
if (typeof codeValueEq === 'string') {
|
|
28
|
+
andConditions.push({ codeValue: { $exists: true, $eq: codeValueEq } });
|
|
29
|
+
}
|
|
30
|
+
const codeValueIn = (_b = params.codeValue) === null || _b === void 0 ? void 0 : _b.$in;
|
|
31
|
+
if (Array.isArray(codeValueIn)) {
|
|
32
|
+
andConditions.push({ codeValue: { $exists: true, $in: codeValueIn } });
|
|
33
|
+
}
|
|
34
|
+
return andConditions;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 検索
|
|
38
|
+
*/
|
|
39
|
+
search(params, inclusion, exclusion) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
42
|
+
let projection = {};
|
|
43
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
44
|
+
inclusion.forEach((field) => {
|
|
45
|
+
projection[field] = 1;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
projection = {
|
|
50
|
+
__v: 0,
|
|
51
|
+
createdAt: 0,
|
|
52
|
+
updatedAt: 0
|
|
53
|
+
};
|
|
54
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
55
|
+
exclusion.forEach((field) => {
|
|
56
|
+
projection[field] = 0;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const query = this.customerTypeModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
61
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
62
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
63
|
+
query.limit(params.limit)
|
|
64
|
+
.skip(params.limit * (page - 1));
|
|
65
|
+
}
|
|
66
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
67
|
+
/* istanbul ignore else */
|
|
68
|
+
if (params.sort !== undefined) {
|
|
69
|
+
query.sort(params.sort);
|
|
70
|
+
}
|
|
71
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
72
|
+
.exec()
|
|
73
|
+
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
saveManyByCodeValue(params) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const bulkWriteOps = [];
|
|
79
|
+
if (Array.isArray(params)) {
|
|
80
|
+
params.forEach((p) => {
|
|
81
|
+
const $set = Object.assign({}, p.attributes);
|
|
82
|
+
if (typeof $set.id === 'string') {
|
|
83
|
+
delete $set.id;
|
|
84
|
+
}
|
|
85
|
+
bulkWriteOps.push({
|
|
86
|
+
updateOne: {
|
|
87
|
+
filter: {
|
|
88
|
+
codeValue: { $eq: p.attributes.codeValue }
|
|
89
|
+
},
|
|
90
|
+
update: {
|
|
91
|
+
$set
|
|
92
|
+
// $setOnInsert: {}
|
|
93
|
+
},
|
|
94
|
+
upsert: (p.upsert !== undefined) ? p.upsert : false
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (bulkWriteOps.length > 0) {
|
|
100
|
+
return this.customerTypeModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.MongoRepository = MongoRepository;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSchema = exports.indexes = exports.modelName = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const writeConcern_1 = require("../writeConcern");
|
|
6
|
+
const settings_1 = require("../../../settings");
|
|
7
|
+
const modelName = 'CustomerType';
|
|
8
|
+
exports.modelName = modelName;
|
|
9
|
+
const schemaDefinition = {
|
|
10
|
+
typeOf: { type: String, required: true },
|
|
11
|
+
codeValue: { type: String, required: true },
|
|
12
|
+
name: mongoose_1.SchemaTypes.Mixed
|
|
13
|
+
};
|
|
14
|
+
const schemaOptions = {
|
|
15
|
+
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
16
|
+
autoCreate: false,
|
|
17
|
+
collection: 'customerTypes',
|
|
18
|
+
id: true,
|
|
19
|
+
read: settings_1.MONGO_READ_PREFERENCE,
|
|
20
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
21
|
+
strict: true,
|
|
22
|
+
strictQuery: false,
|
|
23
|
+
timestamps: {
|
|
24
|
+
createdAt: 'createdAt',
|
|
25
|
+
updatedAt: 'updatedAt'
|
|
26
|
+
},
|
|
27
|
+
toJSON: {
|
|
28
|
+
getters: false,
|
|
29
|
+
virtuals: false,
|
|
30
|
+
minimize: false,
|
|
31
|
+
versionKey: false
|
|
32
|
+
},
|
|
33
|
+
toObject: {
|
|
34
|
+
getters: false,
|
|
35
|
+
virtuals: true,
|
|
36
|
+
minimize: false,
|
|
37
|
+
versionKey: false
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const indexes = [
|
|
41
|
+
[
|
|
42
|
+
{ createdAt: 1 },
|
|
43
|
+
{ name: 'searchByCreatedAt' }
|
|
44
|
+
],
|
|
45
|
+
[
|
|
46
|
+
{ updatedAt: 1 },
|
|
47
|
+
{ name: 'searchByUpdatedAt' }
|
|
48
|
+
]
|
|
49
|
+
];
|
|
50
|
+
exports.indexes = indexes;
|
|
51
|
+
/**
|
|
52
|
+
* カスタマータイプスキーマ
|
|
53
|
+
*/
|
|
54
|
+
let schema;
|
|
55
|
+
function createSchema() {
|
|
56
|
+
if (schema === undefined) {
|
|
57
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
58
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
59
|
+
indexes.forEach((indexParams) => {
|
|
60
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return schema;
|
|
65
|
+
}
|
|
66
|
+
exports.createSchema = createSchema;
|
|
@@ -32,7 +32,7 @@ const schemaDefinition = {
|
|
|
32
32
|
isGift: Boolean,
|
|
33
33
|
dateReturned: Date,
|
|
34
34
|
orderedItem: [mongoose_1.SchemaTypes.Mixed],
|
|
35
|
-
additionalProperty:
|
|
35
|
+
additionalProperty: mongoose_1.SchemaTypes.Mixed // 追加(2023-02-13~) // 廃止(2024-04-12~)
|
|
36
36
|
};
|
|
37
37
|
const schemaOptions = {
|
|
38
38
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IndexDefinition, IndexOptions, Schema } from 'mongoose';
|
|
2
2
|
declare const modelName = "Product";
|
|
3
|
-
declare function createSchema(): Schema;
|
|
4
3
|
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
4
|
+
declare function createSchema(): Schema;
|
|
5
5
|
export { modelName, indexes, createSchema };
|
|
@@ -8,21 +8,15 @@ const modelName = 'Product';
|
|
|
8
8
|
exports.modelName = modelName;
|
|
9
9
|
const schemaDefinition = {
|
|
10
10
|
project: mongoose_1.SchemaTypes.Mixed,
|
|
11
|
-
typeOf: {
|
|
12
|
-
type: String,
|
|
13
|
-
required: true
|
|
14
|
-
},
|
|
11
|
+
typeOf: { type: String, required: true },
|
|
15
12
|
additionalProperty: [mongoose_1.SchemaTypes.Mixed],
|
|
16
13
|
availableChannel: mongoose_1.SchemaTypes.Mixed,
|
|
17
14
|
description: mongoose_1.SchemaTypes.Mixed,
|
|
18
15
|
hasOfferCatalog: mongoose_1.SchemaTypes.Mixed,
|
|
19
16
|
name: mongoose_1.SchemaTypes.Mixed,
|
|
20
17
|
offers: [mongoose_1.SchemaTypes.Mixed],
|
|
21
|
-
productID: {
|
|
22
|
-
|
|
23
|
-
required: true
|
|
24
|
-
},
|
|
25
|
-
provider: [mongoose_1.SchemaTypes.Mixed],
|
|
18
|
+
productID: { type: String, required: true },
|
|
19
|
+
// provider: [SchemaTypes.Mixed], // 廃止(2024-04-12~)
|
|
26
20
|
serviceOutput: mongoose_1.SchemaTypes.Mixed,
|
|
27
21
|
serviceType: mongoose_1.SchemaTypes.Mixed
|
|
28
22
|
};
|
|
@@ -52,17 +46,6 @@ const schemaOptions = {
|
|
|
52
46
|
versionKey: false
|
|
53
47
|
}
|
|
54
48
|
};
|
|
55
|
-
/**
|
|
56
|
-
* プロダクトスキーマ
|
|
57
|
-
*/
|
|
58
|
-
let schema;
|
|
59
|
-
function createSchema() {
|
|
60
|
-
if (schema === undefined) {
|
|
61
|
-
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
62
|
-
}
|
|
63
|
-
return schema;
|
|
64
|
-
}
|
|
65
|
-
exports.createSchema = createSchema;
|
|
66
49
|
const indexes = [
|
|
67
50
|
[
|
|
68
51
|
{ createdAt: 1 },
|
|
@@ -74,15 +57,11 @@ const indexes = [
|
|
|
74
57
|
],
|
|
75
58
|
[
|
|
76
59
|
{ productID: 1 },
|
|
77
|
-
{
|
|
78
|
-
name: 'searchByProductID'
|
|
79
|
-
}
|
|
60
|
+
{ name: 'searchByProductID' }
|
|
80
61
|
],
|
|
81
62
|
[
|
|
82
63
|
{ 'project.id': 1, productID: 1 },
|
|
83
|
-
{
|
|
84
|
-
name: 'searchByProjectId-v20220721'
|
|
85
|
-
}
|
|
64
|
+
{ name: 'searchByProjectId-v20220721' }
|
|
86
65
|
],
|
|
87
66
|
[
|
|
88
67
|
{ 'hasOfferCatalog.id': 1, productID: 1 },
|
|
@@ -122,9 +101,7 @@ const indexes = [
|
|
|
122
101
|
],
|
|
123
102
|
[
|
|
124
103
|
{ typeOf: 1, productID: 1 },
|
|
125
|
-
{
|
|
126
|
-
name: 'searchByTypeOf'
|
|
127
|
-
}
|
|
104
|
+
{ name: 'searchByTypeOf' }
|
|
128
105
|
],
|
|
129
106
|
[
|
|
130
107
|
{ 'name.ja': 1, productID: 1 },
|
|
@@ -143,15 +120,22 @@ const indexes = [
|
|
|
143
120
|
'name.en': { $exists: true }
|
|
144
121
|
}
|
|
145
122
|
}
|
|
146
|
-
],
|
|
147
|
-
[
|
|
148
|
-
{ 'provider.id': 1, productID: 1 },
|
|
149
|
-
{
|
|
150
|
-
name: 'searchByProviderId',
|
|
151
|
-
partialFilterExpression: {
|
|
152
|
-
'provider.id': { $exists: true }
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
123
|
]
|
|
156
124
|
];
|
|
157
125
|
exports.indexes = indexes;
|
|
126
|
+
/**
|
|
127
|
+
* プロダクトスキーマ
|
|
128
|
+
*/
|
|
129
|
+
let schema;
|
|
130
|
+
function createSchema() {
|
|
131
|
+
if (schema === undefined) {
|
|
132
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
133
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
134
|
+
indexes.forEach((indexParams) => {
|
|
135
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return schema;
|
|
140
|
+
}
|
|
141
|
+
exports.createSchema = createSchema;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSchema = exports.indexes = exports.modelName = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const writeConcern_1 = require("../writeConcern");
|
|
6
|
+
const settings_1 = require("../../../settings");
|
|
7
|
+
const modelName = 'ProductModel';
|
|
8
|
+
exports.modelName = modelName;
|
|
9
|
+
const schemaDefinition = {
|
|
10
|
+
project: mongoose_1.SchemaTypes.Mixed,
|
|
11
|
+
typeOf: { type: String, required: true },
|
|
12
|
+
category: mongoose_1.SchemaTypes.Mixed,
|
|
13
|
+
name: mongoose_1.SchemaTypes.Mixed,
|
|
14
|
+
offers: mongoose_1.SchemaTypes.Mixed
|
|
15
|
+
};
|
|
16
|
+
const schemaOptions = {
|
|
17
|
+
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
18
|
+
autoCreate: false,
|
|
19
|
+
collection: 'productModels',
|
|
20
|
+
id: true,
|
|
21
|
+
read: settings_1.MONGO_READ_PREFERENCE,
|
|
22
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
23
|
+
strict: true,
|
|
24
|
+
strictQuery: false,
|
|
25
|
+
timestamps: {
|
|
26
|
+
createdAt: 'createdAt',
|
|
27
|
+
updatedAt: 'updatedAt'
|
|
28
|
+
},
|
|
29
|
+
toJSON: {
|
|
30
|
+
getters: false,
|
|
31
|
+
virtuals: false,
|
|
32
|
+
minimize: false,
|
|
33
|
+
versionKey: false
|
|
34
|
+
},
|
|
35
|
+
toObject: {
|
|
36
|
+
getters: false,
|
|
37
|
+
virtuals: true,
|
|
38
|
+
minimize: false,
|
|
39
|
+
versionKey: false
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const indexes = [
|
|
43
|
+
[
|
|
44
|
+
{ createdAt: 1 },
|
|
45
|
+
{ name: 'searchByCreatedAt' }
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
{ updatedAt: 1 },
|
|
49
|
+
{ name: 'searchByUpdatedAt' }
|
|
50
|
+
]
|
|
51
|
+
];
|
|
52
|
+
exports.indexes = indexes;
|
|
53
|
+
/**
|
|
54
|
+
* プロダクトモデルスキーマ
|
|
55
|
+
*/
|
|
56
|
+
let schema;
|
|
57
|
+
function createSchema() {
|
|
58
|
+
if (schema === undefined) {
|
|
59
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
60
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
61
|
+
indexes.forEach((indexParams) => {
|
|
62
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return schema;
|
|
67
|
+
}
|
|
68
|
+
exports.createSchema = createSchema;
|
|
@@ -69,12 +69,10 @@ export declare class MongoRepository {
|
|
|
69
69
|
/**
|
|
70
70
|
* 変更可能な属性を更新する
|
|
71
71
|
*/
|
|
72
|
-
updateChangeableAttributes(params: {
|
|
72
|
+
updateChangeableAttributes(params: Pick<factory.order.IOrder, 'name'> & {
|
|
73
73
|
project: {
|
|
74
74
|
id: string;
|
|
75
75
|
};
|
|
76
|
-
additionalProperty?: factory.propertyValue.IPropertyValue<string>[];
|
|
77
|
-
name?: string;
|
|
78
76
|
orderNumber: string;
|
|
79
77
|
}): Promise<{
|
|
80
78
|
updatedAt: Date;
|
|
@@ -144,7 +142,7 @@ export declare class MongoRepository {
|
|
|
144
142
|
})[]>;
|
|
145
143
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
146
144
|
unsetUnnecessaryFields(params: {
|
|
147
|
-
filter: FilterQuery<
|
|
145
|
+
filter: FilterQuery<factory.order.IOrder>;
|
|
148
146
|
$unset: any;
|
|
149
147
|
}): Promise<import("mongodb").UpdateResult>;
|
|
150
148
|
}
|