UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

77 lines (76 loc) 2.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const mongoose = require("mongoose"); const multilingualString_1 = require("../schemaTypes/multilingualString"); const safe = { j: true, w: 'majority', wtimeout: 10000 }; const containedInPlaceSchema = new mongoose.Schema({}, { id: false, _id: false, strict: false }); const containsPlaceSchema = new mongoose.Schema({}, { id: false, _id: false, strict: false }); const openingHoursSpecificationSchema = new mongoose.Schema({}, { id: false, _id: false, strict: false }); const offersSchema = new mongoose.Schema({}, { id: false, _id: false, strict: false }); /** * 場所スキーマ */ const schema = new mongoose.Schema({ _id: String, typeOf: { type: String, required: true }, name: multilingualString_1.default, alternateName: multilingualString_1.default, description: multilingualString_1.default, address: multilingualString_1.default, branchCode: String, containedInPlace: containedInPlaceSchema, containsPlace: [containsPlaceSchema], maximumAttendeeCapacity: Number, openingHoursSpecification: openingHoursSpecificationSchema, smokingAllowed: Boolean, telephone: String, sameAs: String, url: String, kanaName: String, offers: offersSchema }, { collection: 'places', id: true, read: 'primaryPreferred', safe: safe, strict: true, useNestedStrict: true, timestamps: { createdAt: 'createdAt', updatedAt: 'updatedAt' }, toJSON: { getters: true }, toObject: { getters: true } }); schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' }); schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' }); // 劇場検索に使用 schema.index({ branchCode: 1, typeOf: 1 }); exports.default = mongoose.model('Place', schema).on('index', // tslint:disable-next-line:no-single-line-block-comment /* istanbul ignore next */ (error) => { if (error !== undefined) { // tslint:disable-next-line:no-console console.error(error); } });