UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

61 lines (60 loc) 2.71 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ReserveInterfaceRepo = void 0; const reserveInterface_1 = require("./mongoose/schemas/reserveInterface"); /** * ReserveIFリポジトリ */ class ReserveInterfaceRepo { constructor(connection) { this.reserveInterface = connection.model(reserveInterface_1.modelName, (0, reserveInterface_1.createSchema)()); } // public async saveOne(params: factory.service.webAPI.IServiceWithChannel): Promise<void> { // await this.reserveInterface.create(params); // } findOne(filter) { return __awaiter(this, void 0, void 0, function* () { var _a, _b, _c; const andQuery = []; const idEq = (_a = filter.id) === null || _a === void 0 ? void 0 : _a.$eq; if (typeof idEq === 'string') { andQuery.push({ _id: { $eq: idEq } }); } const projectIdEq = (_c = (_b = filter.project) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.$eq; if (typeof projectIdEq === 'string') { andQuery.push({ 'project.id': { $eq: projectIdEq } }); } const filterQuery = Object.assign({}, (andQuery.length > 0) ? { $and: andQuery } : undefined); return this.reserveInterface.findOne(filterQuery, { _id: 0, id: { $toString: '$_id' }, project: '$project', availableChannel: '$availableChannel', typeOf: '$typeOf' }) .lean() .exec(); }); } findOneId() { return __awaiter(this, void 0, void 0, function* () { return this.reserveInterface.findOne({}, { _id: 0, id: { $toString: '$_id' }, project: '$project' }) .lean() .exec(); }); } } exports.ReserveInterfaceRepo = ReserveInterfaceRepo;