UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

128 lines (127 loc) 3.44 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 = 'Seller'; exports.modelName = modelName; const schemaDefinition = { additionalProperty: [mongoose_1.SchemaTypes.Mixed], // areaServed: [SchemaTypes.Mixed], branchCode: String, hasMerchantReturnPolicy: [mongoose_1.SchemaTypes.Mixed], makesOffer: [mongoose_1.SchemaTypes.Mixed], name: mongoose_1.SchemaTypes.Mixed, // parentOrganization: SchemaTypes.Mixed, paymentAccepted: [mongoose_1.SchemaTypes.Mixed], project: mongoose_1.SchemaTypes.Mixed, typeOf: { type: String, required: true }, url: String, telephone: String }; const schemaOptions = { autoIndex: settings_1.MONGO_AUTO_INDEX, autoCreate: false, collection: 'sellers', id: true, read: settings_1.MONGO_READ_PREFERENCE, writeConcern: writeConcern_1.writeConcern, strict: true, strictQuery: false, timestamps: false, // 2024-08-22~ versionKey: false, // 2024-08-22~ toJSON: { getters: false, virtuals: false, minimize: false, versionKey: false }, toObject: { getters: false, virtuals: true, minimize: false, versionKey: false } }; const indexes = [ [ { branchCode: 1 }, { name: 'searchByBranchCode' } ], [ { typeOf: 1, branchCode: 1 }, { name: 'searchByTypeOf' } ], [ { 'project.id': 1, branchCode: 1 }, { name: 'searchByProjectId-v20220721' } ], [ { 'name.ja': 1, branchCode: 1 }, { name: 'searchByNameJa', partialFilterExpression: { 'name.ja': { $exists: true } } } ], [ { 'name.en': 1, branchCode: 1 }, { name: 'searchByNameEn', partialFilterExpression: { 'name.en': { $exists: true } } } ], [ { additionalProperty: 1, branchCode: 1 }, { name: 'searchByAdditionalProperty', partialFilterExpression: { additionalProperty: { $exists: true } } } ], [ { 'paymentAccepted.paymentMethodType': 1, branchCode: 1 }, { name: 'searchByPaymentAccepted', partialFilterExpression: { 'paymentAccepted.paymentMethodType': { $exists: true } } } ], [ { 'hasMerchantReturnPolicy.identifier': 1, branchCode: 1 }, { name: 'hasMerchantReturnPolicyIdentifier', partialFilterExpression: { 'hasMerchantReturnPolicy.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; }