@chevre/domain 20.1.0-alpha.20 → 20.1.0-alpha.21
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/{migrateEventSeriesAdditionalPropertyNames.ts → migrateEventSeriesAdditionalProperties.ts} +29 -1
- package/lib/chevre/repo/{additionalPropertyName.d.ts → additionalProperty.d.ts} +2 -2
- package/lib/chevre/repo/{additionalPropertyName.js → additionalProperty.js} +12 -12
- package/lib/chevre/repo/mongoose/model/{additionalPropertyName.d.ts → additionalProperty.d.ts} +2 -2
- package/lib/chevre/repo/mongoose/model/{additionalPropertyName.js → additionalProperty.js} +3 -3
- package/lib/chevre/repository.d.ts +3 -3
- package/lib/chevre/repository.js +5 -5
- package/package.json +1 -1
|
@@ -12,6 +12,7 @@ async function main() {
|
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
13
13
|
|
|
14
14
|
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
15
|
+
const additionalPropertyRepo = new chevre.repository.AdditionalProperty(mongoose.connection);
|
|
15
16
|
|
|
16
17
|
const cursor = eventRepo.getCursor(
|
|
17
18
|
{
|
|
@@ -36,7 +37,7 @@ async function main() {
|
|
|
36
37
|
const projectIds: string[] = [];
|
|
37
38
|
|
|
38
39
|
let i = 0;
|
|
39
|
-
|
|
40
|
+
let updateCount = 0;
|
|
40
41
|
await cursor.eachAsync(async (doc) => {
|
|
41
42
|
i += 1;
|
|
42
43
|
const event: chevre.factory.event.screeningEventSeries.IEvent = doc.toObject();
|
|
@@ -55,6 +56,33 @@ async function main() {
|
|
|
55
56
|
throw new Error(`length matched ${event.project.id} ${event.id} ${name}`);
|
|
56
57
|
}
|
|
57
58
|
});
|
|
59
|
+
|
|
60
|
+
for (const additionalPropertyNameOnEvent of additionalPropertyNamesOnEvent) {
|
|
61
|
+
const existings = await additionalPropertyRepo.search({
|
|
62
|
+
project: { id: { $eq: event.project.id } },
|
|
63
|
+
limit: 1,
|
|
64
|
+
page: 1,
|
|
65
|
+
name: { $regex: `^${additionalPropertyNameOnEvent}$` }
|
|
66
|
+
});
|
|
67
|
+
if (existings.length > 0) {
|
|
68
|
+
console.log('already existed', additionalPropertyNameOnEvent, event.id, event.project.id);
|
|
69
|
+
} else {
|
|
70
|
+
updateCount += 1;
|
|
71
|
+
await additionalPropertyRepo.save({
|
|
72
|
+
attributes: {
|
|
73
|
+
project: event.project,
|
|
74
|
+
typeOf: 'CategoryCode',
|
|
75
|
+
codeValue: additionalPropertyNameOnEvent,
|
|
76
|
+
inCodeSet: {
|
|
77
|
+
typeOf: 'CategoryCodeSet',
|
|
78
|
+
identifier: <any>event.typeOf
|
|
79
|
+
},
|
|
80
|
+
name: { ja: additionalPropertyNameOnEvent }
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
console.log('created', additionalPropertyNameOnEvent, event.id, event.project.id);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
58
86
|
}
|
|
59
87
|
});
|
|
60
88
|
console.log(i, 'events checked');
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Connection } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 追加特性リポジトリ
|
|
5
5
|
*/
|
|
6
6
|
export declare class MongoRepository {
|
|
7
|
-
private readonly
|
|
7
|
+
private readonly additionalPropertyModel;
|
|
8
8
|
constructor(connection: Connection);
|
|
9
9
|
static CREATE_MONGO_CONDITIONS(params: factory.categoryCode.ISearchConditions): any[];
|
|
10
10
|
/**
|
|
@@ -21,14 +21,14 @@ 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
|
|
24
|
+
const additionalProperty_1 = require("./mongoose/model/additionalProperty");
|
|
25
25
|
const factory = require("../factory");
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* 追加特性リポジトリ
|
|
28
28
|
*/
|
|
29
29
|
class MongoRepository {
|
|
30
30
|
constructor(connection) {
|
|
31
|
-
this.
|
|
31
|
+
this.additionalPropertyModel = connection.model(additionalProperty_1.modelName);
|
|
32
32
|
}
|
|
33
33
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
34
34
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
@@ -126,7 +126,7 @@ class MongoRepository {
|
|
|
126
126
|
}
|
|
127
127
|
// public async count(params: factory.categoryCode.ISearchConditions): Promise<number> {
|
|
128
128
|
// const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
129
|
-
// return this.
|
|
129
|
+
// return this.additionalPropertyModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
|
|
130
130
|
// .setOptions({ maxTimeMS: 10000 })
|
|
131
131
|
// .exec();
|
|
132
132
|
// }
|
|
@@ -136,7 +136,7 @@ class MongoRepository {
|
|
|
136
136
|
search(params) {
|
|
137
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
138
138
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
139
|
-
const query = this.
|
|
139
|
+
const query = this.additionalPropertyModel.find((conditions.length > 0) ? { $and: conditions } : {}, {
|
|
140
140
|
__v: 0,
|
|
141
141
|
createdAt: 0,
|
|
142
142
|
updatedAt: 0
|
|
@@ -158,14 +158,14 @@ class MongoRepository {
|
|
|
158
158
|
}
|
|
159
159
|
findById(params) {
|
|
160
160
|
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
const doc = yield this.
|
|
161
|
+
const doc = yield this.additionalPropertyModel.findOne({ _id: params.id }, {
|
|
162
162
|
__v: 0,
|
|
163
163
|
createdAt: 0,
|
|
164
164
|
updatedAt: 0
|
|
165
165
|
})
|
|
166
166
|
.exec();
|
|
167
167
|
if (doc === null) {
|
|
168
|
-
throw new factory.errors.NotFound(this.
|
|
168
|
+
throw new factory.errors.NotFound(this.additionalPropertyModel.modelName);
|
|
169
169
|
}
|
|
170
170
|
return doc.toObject();
|
|
171
171
|
});
|
|
@@ -174,15 +174,15 @@ class MongoRepository {
|
|
|
174
174
|
return __awaiter(this, void 0, void 0, function* () {
|
|
175
175
|
let doc;
|
|
176
176
|
if (typeof params.id !== 'string') {
|
|
177
|
-
doc = yield this.
|
|
177
|
+
doc = yield this.additionalPropertyModel.create(params.attributes);
|
|
178
178
|
}
|
|
179
179
|
else {
|
|
180
180
|
const _a = params.attributes, { id, codeValue, inCodeSet, project, typeOf } = _a, updateFields = __rest(_a, ["id", "codeValue", "inCodeSet", "project", "typeOf"]);
|
|
181
|
-
doc = yield this.
|
|
181
|
+
doc = yield this.additionalPropertyModel.findOneAndUpdate({ _id: params.id }, updateFields, { upsert: false, new: true })
|
|
182
182
|
.exec();
|
|
183
183
|
}
|
|
184
184
|
if (doc === null) {
|
|
185
|
-
throw new factory.errors.NotFound(this.
|
|
185
|
+
throw new factory.errors.NotFound(this.additionalPropertyModel.modelName);
|
|
186
186
|
}
|
|
187
187
|
return doc.toObject();
|
|
188
188
|
});
|
|
@@ -192,7 +192,7 @@ class MongoRepository {
|
|
|
192
192
|
*/
|
|
193
193
|
deleteById(params) {
|
|
194
194
|
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
-
yield this.
|
|
195
|
+
yield this.additionalPropertyModel.findOneAndRemove({ _id: params.id })
|
|
196
196
|
.exec();
|
|
197
197
|
});
|
|
198
198
|
}
|
|
@@ -201,7 +201,7 @@ class MongoRepository {
|
|
|
201
201
|
*/
|
|
202
202
|
deleteByProject(params) {
|
|
203
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
-
yield this.
|
|
204
|
+
yield this.additionalPropertyModel.deleteMany({
|
|
205
205
|
'project.id': { $eq: params.project.id }
|
|
206
206
|
})
|
|
207
207
|
.exec();
|
package/lib/chevre/repo/mongoose/model/{additionalPropertyName.d.ts → additionalProperty.d.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as mongoose from 'mongoose';
|
|
2
|
-
declare const modelName = "
|
|
2
|
+
declare const modelName = "AdditionalProperty";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 追加特性スキーマ
|
|
5
5
|
*/
|
|
6
6
|
declare const schema: mongoose.Schema<mongoose.Document<any, any, any>, mongoose.Model<mongoose.Document<any, any, any>, any, any>, undefined, {}>;
|
|
7
7
|
export { modelName, schema };
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.schema = exports.modelName = void 0;
|
|
4
4
|
const mongoose = require("mongoose");
|
|
5
|
-
const modelName = '
|
|
5
|
+
const modelName = 'AdditionalProperty';
|
|
6
6
|
exports.modelName = modelName;
|
|
7
7
|
const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* 追加特性スキーマ
|
|
10
10
|
*/
|
|
11
11
|
const schema = new mongoose.Schema({
|
|
12
12
|
project: mongoose.SchemaTypes.Mixed,
|
|
@@ -21,7 +21,7 @@ const schema = new mongoose.Schema({
|
|
|
21
21
|
inCodeSet: mongoose.SchemaTypes.Mixed,
|
|
22
22
|
name: mongoose.SchemaTypes.Mixed
|
|
23
23
|
}, {
|
|
24
|
-
collection: '
|
|
24
|
+
collection: 'additionalProperties',
|
|
25
25
|
id: true,
|
|
26
26
|
read: 'primaryPreferred',
|
|
27
27
|
writeConcern: writeConcern,
|
|
@@ -7,7 +7,7 @@ import { MongoRepository as AccountingReportRepo } from './repo/accountingReport
|
|
|
7
7
|
import { MongoRepository as AccountTitleRepo } from './repo/accountTitle';
|
|
8
8
|
import { MongoRepository as AccountTransactionRepo } from './repo/accountTransaction';
|
|
9
9
|
import { MongoRepository as ActionRepo } from './repo/action';
|
|
10
|
-
import { MongoRepository as
|
|
10
|
+
import { MongoRepository as AdditionalPropertyRepo } from './repo/additionalProperty';
|
|
11
11
|
import { MongoRepository as AssetTransactionRepo } from './repo/assetTransaction';
|
|
12
12
|
import { MongoRepository as CategoryCodeRepo } from './repo/categoryCode';
|
|
13
13
|
import { MongoRepository as CodeRepo } from './repo/code';
|
|
@@ -67,9 +67,9 @@ export declare class AccountTransaction extends AccountTransactionRepo {
|
|
|
67
67
|
export declare class Action extends ActionRepo {
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
70
|
+
* 追加特性リポジトリ
|
|
71
71
|
*/
|
|
72
|
-
export declare class
|
|
72
|
+
export declare class AdditionalProperty extends AdditionalPropertyRepo {
|
|
73
73
|
}
|
|
74
74
|
export declare namespace action {
|
|
75
75
|
class RegisterServiceInProgress extends RegisterServiceActionInProgress {
|
package/lib/chevre/repository.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rateLimit = exports.itemAvailability = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.OfferCatalog = exports.Offer = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.
|
|
3
|
+
exports.rateLimit = exports.itemAvailability = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.OfferCatalog = exports.Offer = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.AccountAction = exports.Account = void 0;
|
|
4
4
|
// tslint:disable:max-classes-per-file completed-docs
|
|
5
5
|
/**
|
|
6
6
|
* リポジトリ
|
|
@@ -11,7 +11,7 @@ const accountingReport_1 = require("./repo/accountingReport");
|
|
|
11
11
|
const accountTitle_1 = require("./repo/accountTitle");
|
|
12
12
|
const accountTransaction_1 = require("./repo/accountTransaction");
|
|
13
13
|
const action_1 = require("./repo/action");
|
|
14
|
-
const
|
|
14
|
+
const additionalProperty_1 = require("./repo/additionalProperty");
|
|
15
15
|
const assetTransaction_1 = require("./repo/assetTransaction");
|
|
16
16
|
const categoryCode_1 = require("./repo/categoryCode");
|
|
17
17
|
const code_1 = require("./repo/code");
|
|
@@ -77,11 +77,11 @@ class Action extends action_1.MongoRepository {
|
|
|
77
77
|
}
|
|
78
78
|
exports.Action = Action;
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
80
|
+
* 追加特性リポジトリ
|
|
81
81
|
*/
|
|
82
|
-
class
|
|
82
|
+
class AdditionalProperty extends additionalProperty_1.MongoRepository {
|
|
83
83
|
}
|
|
84
|
-
exports.
|
|
84
|
+
exports.AdditionalProperty = AdditionalProperty;
|
|
85
85
|
var action;
|
|
86
86
|
(function (action) {
|
|
87
87
|
class RegisterServiceInProgress extends registerServiceInProgress_1.RedisRepository {
|
package/package.json
CHANGED