UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

477 lines (476 loc) 13.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.modelName = exports.indexes = void 0; exports.createSchema = createSchema; const mongoose_1 = require("mongoose"); const writeConcern_1 = require("../writeConcern"); const settings_1 = require("../../../settings"); const modelName = 'Action'; exports.modelName = modelName; const schemaDefinition = { project: mongoose_1.SchemaTypes.Mixed, actionStatus: String, typeOf: String, description: String, agent: mongoose_1.SchemaTypes.Mixed, recipient: mongoose_1.SchemaTypes.Mixed, result: mongoose_1.SchemaTypes.Mixed, error: mongoose_1.SchemaTypes.Mixed, object: mongoose_1.SchemaTypes.Mixed, startDate: Date, endDate: Date, purpose: mongoose_1.SchemaTypes.Mixed, potentialActions: mongoose_1.SchemaTypes.Mixed, amount: mongoose_1.SchemaTypes.Mixed, fromLocation: mongoose_1.SchemaTypes.Mixed, toLocation: mongoose_1.SchemaTypes.Mixed, instrument: mongoose_1.SchemaTypes.Mixed, location: mongoose_1.SchemaTypes.Mixed, // add location(2022-11-11~) replacer: mongoose_1.SchemaTypes.Mixed, // add replacer(2024-03-19~) targetCollection: mongoose_1.SchemaTypes.Mixed, // add targetCollection(2024-03-19~) sameAs: mongoose_1.SchemaTypes.Mixed, // タスク関連付けのために追加(2024-04-20~) cancelAction: mongoose_1.SchemaTypes.Mixed, // add(2024-05-26~) about: mongoose_1.SchemaTypes.Mixed, // add(2025-01-22~) target: mongoose_1.SchemaTypes.Mixed, // add(2025-02-06~) identifier: mongoose_1.SchemaTypes.Mixed // add(2025-02-06~) }; const schemaOptions = { autoIndex: settings_1.MONGO_AUTO_INDEX, autoCreate: false, collection: 'actions', id: true, read: 'primary', writeConcern: writeConcern_1.writeConcern, strict: true, strictQuery: false, timestamps: false, versionKey: false, toJSON: { getters: false, virtuals: false, minimize: false, versionKey: false }, toObject: { getters: false, virtuals: true, minimize: false, versionKey: false } }; const indexes = [ [ { 'project.id': 1, startDate: -1 }, { name: 'searchByProjectId-v20220721' } ], [ { typeOf: 1, startDate: -1 }, { name: 'searchByTypeOf-v2' } ], [ { actionStatus: 1, startDate: -1 }, { name: 'searchByActionStatus-v2' } ], [ { startDate: -1 }, { name: 'searchByStartDate-v2' } ], [ { endDate: -1, startDate: -1 }, { name: 'searchByEndDate-v2', partialFilterExpression: { endDate: { $exists: true } } } ], [ { 'location.id': 1, startDate: -1 }, { name: 'searchByLocationId', partialFilterExpression: { 'location.id': { $exists: true } } } ], [ { 'location.identifier': 1, startDate: -1 }, { name: 'searchByLocationIdentifier', partialFilterExpression: { 'location.identifier': { $exists: true } } } ], [ { 'agent.typeOf': 1, startDate: -1 }, { name: 'searchByAgentTypeOf', partialFilterExpression: { 'agent.typeOf': { $exists: true } } } ], [ { 'agent.id': 1, startDate: -1 }, { name: 'searchByAgentId', partialFilterExpression: { 'agent.id': { $exists: true } } } ], [ { 'purpose.typeOf': 1, startDate: -1 }, { name: 'searchByPurposeTypeOf-v2', partialFilterExpression: { 'purpose.typeOf': { $exists: true } } } ], [ { 'purpose.id': 1, startDate: -1 }, { name: 'searchByPurposeId-v2', partialFilterExpression: { 'purpose.id': { $exists: true } } } ], [ { 'object.typeOf': 1, startDate: -1 }, { name: 'searchByObjectTypeOf-v2', partialFilterExpression: { 'object.typeOf': { $exists: true } } } ], [ { 'object.id': 1, startDate: -1 }, { name: 'searchByObjectId', partialFilterExpression: { 'object.id': { $exists: true } } } ], [ { 'object.movieTickets.identifier': 1, startDate: -1 }, { name: 'searchByObjectMovieTicketsIdentifier', partialFilterExpression: { 'object.movieTickets.identifier': { $exists: true } } } ], [ { 'object.movieTickets.serviceOutput.reservationFor.id': 1, startDate: -1 }, { name: 'searchByObjectMovieTicketsServiceOutputReservationForId', partialFilterExpression: { 'object.movieTickets.serviceOutput.reservationFor.id': { $exists: true } } } ], [ { 'object.paymentMethod.accountId': 1, startDate: -1 }, { name: 'searchByObjectPaymentMethodAccountId', partialFilterExpression: { 'object.paymentMethod.accountId': { $exists: true } } } ], [ { 'object.paymentMethod.paymentMethodId': 1, startDate: -1 }, { name: 'searchByObjectPaymentMethodPaymentMethodId', partialFilterExpression: { 'object.paymentMethod.paymentMethodId': { $exists: true } } } ], [ { 'object.paymentMethod.typeOf': 1, startDate: -1 }, { name: 'searchByObjectPaymentMethodTypeOf', partialFilterExpression: { 'object.paymentMethod.typeOf': { $exists: true } } } ], [ { 'object.paymentMethodId': 1, startDate: -1 }, { name: 'searchByObjectPaymentMethodId', partialFilterExpression: { 'object.paymentMethodId': { $exists: true } } } ], [ { 'object.object.paymentMethodId': 1, startDate: -1 }, { name: 'searchByObjectObjectPaymentMethodId', partialFilterExpression: { 'object.object.paymentMethodId': { $exists: true } } } ], [ { 'object.event.id': 1, startDate: -1 }, { name: 'searchByObjectEventId', partialFilterExpression: { 'object.event.id': { $exists: true } } } ], [ { 'about.id': 1, startDate: -1 }, { name: 'aboutId', partialFilterExpression: { 'about.id': { $exists: true } } } ], [ { 'about.orderNumber': 1, startDate: -1 }, { name: 'aboutOrderNumber', partialFilterExpression: { 'about.orderNumber': { $exists: true } } } ], [ { 'object.orderNumber': 1, startDate: -1 }, { name: 'searchByObjectOrderNumber-v2', partialFilterExpression: { 'object.orderNumber': { $exists: true } } } ], [ { 'purpose.orderNumber': 1, startDate: -1 }, { name: 'searchByPurposeOrderNumber-v2', partialFilterExpression: { 'purpose.orderNumber': { $exists: true } } } ], [ { 'object.reservationFor.id': 1, startDate: -1 }, { name: 'searchByObjectReservationForId', partialFilterExpression: { 'object.reservationFor.id': { $exists: true } } } ], [ { 'object.reservationNumber': 1, startDate: -1 }, { name: 'searchByObjectReservationNumber', partialFilterExpression: { 'object.reservationNumber': { $exists: true } } } ], [ { 'object.reservedTicket.ticketType.id': 1, startDate: -1 }, { name: 'searchByObjectReservedTicketTicketTypeId', partialFilterExpression: { 'object.reservedTicket.ticketType.id': { $exists: true } } } ], [ { 'result.typeOf': 1, startDate: -1 }, { name: 'searchByResultTypeOf', partialFilterExpression: { 'result.typeOf': { $exists: true } } } ], [ { 'result.id': 1, startDate: -1 }, { name: 'searchByResultId', partialFilterExpression: { 'result.id': { $exists: true } } } ], [ { 'result.code': 1, startDate: -1 }, { name: 'searchByResultCode', partialFilterExpression: { 'result.code': { $exists: true } } } ], [ { 'result.orderNumber': 1, startDate: -1 }, { name: 'searchByResultOrderNumber', partialFilterExpression: { 'result.orderNumber': { $exists: true } } } ], [ { 'fromLocation.typeOf': 1, startDate: -1 }, { name: 'searchByFromLocationTypeOf', partialFilterExpression: { 'fromLocation.typeOf': { $exists: true } } } ], [ { 'fromLocation.accountNumber': 1, startDate: -1 }, { name: 'searchByFromLocationAccountNumber', partialFilterExpression: { 'fromLocation.accountNumber': { $exists: true } } } ], [ { 'fromLocation.accountType': 1, startDate: -1 }, { name: 'searchByFromLocationAccountType', partialFilterExpression: { 'fromLocation.accountType': { $exists: true } } } ], [ { 'toLocation.typeOf': 1, startDate: -1 }, { name: 'searchByToLocationTypeOf', partialFilterExpression: { 'toLocation.typeOf': { $exists: true } } } ], [ { 'toLocation.accountNumber': 1, startDate: -1 }, { name: 'searchByToLocationAccountNumber', partialFilterExpression: { 'toLocation.accountNumber': { $exists: true } } } ], [ { 'toLocation.accountType': 1, startDate: -1 }, { name: 'searchByToLocationAccountType', partialFilterExpression: { 'toLocation.accountType': { $exists: true } } } ], [ { 'instrument.transactionNumber': 1, startDate: -1 }, { name: 'searchByInstrumentTransactionNumber', partialFilterExpression: { 'instrument.transactionNumber': { $exists: true } } } ], [ { 'instrument.typeOf': 1, startDate: -1 }, { name: 'searchByInstrumentTypeOf', partialFilterExpression: { 'instrument.typeOf': { $exists: true } } } ], [ { 'instrument.identifier': 1, startDate: -1 }, { name: 'instrumentIdentifier', partialFilterExpression: { 'instrument.identifier': { $exists: true } } } ], [ { 'instrument.id': 1, startDate: -1 }, { name: 'instrumentId', partialFilterExpression: { 'instrument.id': { $exists: true } } } ], [ { 'instrument.orderNumber': 1, startDate: -1 }, { name: 'instrumentOrderNumber', partialFilterExpression: { 'instrument.orderNumber': { $exists: true } } } ], [ { 'object.transactionNumber': 1, startDate: -1 }, { name: 'searchByObjectTransactionNumber', partialFilterExpression: { 'object.transactionNumber': { $exists: true } } } ], [ { 'sameAs.id': 1, startDate: -1 }, { name: 'searchBySameAsId', partialFilterExpression: { 'sameAs.id': { $exists: true } } } ], [ // add unique index(2025-02-25~) { identifier: 1 }, { unique: true, name: 'uniqueIdentifier', partialFilterExpression: { identifier: { $exists: true } } } ] ]; exports.indexes = indexes; /** * アクションスキーマ */ let schema; function createSchema() { if (schema === undefined) { schema = new mongoose_1.Schema(schemaDefinition, schemaOptions); } if (settings_1.MONGO_AUTO_INDEX) { indexes.forEach((indexParams) => { schema === null || schema === void 0 ? void 0 : schema.index(...indexParams); }); } return schema; }