UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

172 lines (171 loc) 4.75 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 = 'PaymentService'; exports.modelName = modelName; const schemaDefinition = { availableChannel: { type: mongoose_1.SchemaTypes.Mixed, required: true }, project: { type: mongoose_1.SchemaTypes.Mixed, required: true }, typeOf: { type: String, required: true }, additionalProperty: [mongoose_1.SchemaTypes.Mixed], description: mongoose_1.SchemaTypes.Mixed, name: mongoose_1.SchemaTypes.Mixed, productID: { type: String, required: true }, provider: [mongoose_1.SchemaTypes.Mixed], serviceOutput: mongoose_1.SchemaTypes.Mixed, serviceType: mongoose_1.SchemaTypes.Mixed, potentialAction: mongoose_1.SchemaTypes.Mixed }; const schemaOptions = { autoIndex: settings_1.MONGO_AUTO_INDEX, autoCreate: false, collection: 'paymentServices', id: true, read: settings_1.MONGO_READ_PREFERENCE, 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 = [ [ { productID: 1 }, { name: 'searchByProductID' } ], [ { 'project.id': 1, productID: 1 }, { name: 'uniqueProductID', unique: true } ], [ { 'serviceOutput.typeOf': 1, productID: 1 }, { name: 'searchByServiceOutputTypeOf', partialFilterExpression: { 'serviceOutput.typeOf': { $exists: true } } } ], [ { 'serviceOutput.paymentMethod.amount.currency': 1, productID: 1 }, { name: 'searchByServiceOutputPaymentMethodAmountCurrency', partialFilterExpression: { 'serviceOutput.paymentMethod.amount.currency': { $exists: true } } } ], [ { 'serviceOutput.issuedThrough.serviceType.codeValue': 1, productID: 1 }, { name: 'searchByServiceOutputIssuedThroughServiceType', partialFilterExpression: { 'serviceOutput.issuedThrough.serviceType.codeValue': { $exists: true } } } ], [ { 'serviceType.codeValue': 1, productID: 1 }, { name: 'searchByServiceTypeCodeValue', partialFilterExpression: { 'serviceType.codeValue': { $exists: true } } } ], [ { typeOf: 1, productID: 1 }, { name: 'searchByTypeOf' } ], [ { 'name.ja': 1, productID: 1 }, { name: 'searchByNameJa', partialFilterExpression: { 'name.ja': { $exists: true } } } ], [ { 'name.en': 1, productID: 1 }, { name: 'searchByNameEn', partialFilterExpression: { 'name.en': { $exists: true } } } ], [ { 'provider.id': 1, productID: 1 }, { name: 'searchByProviderId', partialFilterExpression: { 'provider.id': { $exists: true } } } ], [ { 'availableChannel.serviceUrl': 1, productID: 1 }, { name: 'availableChannelServiceUrl', partialFilterExpression: { 'availableChannel.serviceUrl': { $exists: true } } } ], [ { 'availableChannel.id': 1, productID: 1 }, { name: 'availableChannelId', partialFilterExpression: { 'availableChannel.id': { $exists: true } } } ], [ { 'project.id': 1, 'serviceType.codeValue': 1 }, { name: 'uniqueServiceTypeCodeValue', unique: 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; }