UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

172 lines (171 loc) 5.17 kB
import type { BulkWriteResult } from 'mongodb'; import type { Connection, Document, FilterQuery } from 'mongoose'; import * as factory from '../factory'; import { IDocType } from './mongoose/schemas/offerCatalog'; export type IAggregatedOfferCatalog = Pick<factory.offerCatalog.IOfferCatalog, 'id' | 'name' | 'description' | 'project' | 'typeOf' | 'identifier' | 'itemOffered' | 'additionalProperty'> & { numberOfItems?: number; itemListElementTypeOf: factory.offerType.Offer | 'OfferCatalog'; }; type IKeyOfProjection = 'name' | 'description' | 'project' | 'typeOf' | 'id' | 'identifier' | 'itemOffered' | 'additionalProperty' | 'numberOfItems' | 'itemListElementTypeOf' | 'dateSynced'; /** * カタログリポジトリ */ export declare class OfferCatalogRepo { private readonly offerCatalogModel; constructor(connection: Connection); static CREATE_MONGO_CONDITIONS(params: factory.offerCatalog.ISearchConditions): any[]; save(params: factory.offerCatalog.IOfferCatalog & { $unset?: { [key in keyof factory.offerCatalog.IOfferCatalog]?: 1; }; }): Promise<{ id: string; }>; /** * プロジェクトとコードから冪等保管 */ saveByIdentifier(params: factory.offerCatalog.IOfferCatalog): Promise<{ id: string; }>; /** * コードをキーにして冪等置換(2023-12-14~) */ upsertManyByIdentifier(params: { $set: factory.offerCatalog.IOfferCatalog; $unset?: { [key in keyof factory.offerCatalog.IOfferCatalog]?: 1; }; }[]): Promise<{ bulkWriteResult: BulkWriteResult; modifiedCatalogs: { id: string; }[]; } | void>; /** * 同期日時を更新する */ updateDateSynced(params: { id: string; dateSynced: Date; }): Promise<void>; updateManyById(params: { id: { $in: string[]; }; $push: { itemListElement: { $each: factory.offerCatalog.IItemListElement[]; $slice: number; }; }; $pull: { itemListElement: { $elemMatch: { id: { $in: string[]; }; }; }; }; }): Promise<void>; pullItemListElement(params: { project: { id: string; }; $pull: { itemListElement: { $elemMatch: { id: { $in: string[]; }; }; }; }; }): Promise<import("mongoose").UpdateWriteOpResult | undefined>; projectFields(params: factory.offerCatalog.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IAggregatedOfferCatalog[]>; findItemListElementById(params: { id: string; project: { id: string; }; }): Promise<{ itemListElement: { id: string; }[]; }>; /** * 一つ目のitemListElementを取得する */ findFirstItemListElementById(params: { id: string; }): Promise<factory.offerCatalog.IItemListElement>; /** * カタログのitemListElementをpaging有で検索する * reimplement as sliceItemListElementById(2025-05-06=) */ /** * カタログのitemListElementをpaging有で検索する * reimplement using $slice(2025-05-06=) */ sliceItemListElementById(params: { /** * カタログID */ id: string; limit: number; page: number; }): Promise<{ id: string; elementIndex: number; }[]>; /** * カタログIDとアイテムIDからアイテムを全て検索する */ searchItemListElement(params: { id: { $in: string[]; }; itemListElement: { id: { $in: string[]; }; }; }): Promise<{ id: string; }[]>; deleteById(params: { id: string; }): Promise<void>; deleteByProject(params: { project: { id: string; }; }): Promise<void>; getCursor(conditions: any, projection: any): import("mongoose").Cursor<Document<unknown, {}, IDocType> & factory.offerCatalog.IOfferCatalog & { _id: string; alternateName?: any; dateSynced?: Date; } & Required<{ _id: string; }>, import("mongoose").QueryOptions<Document<unknown, {}, IDocType> & factory.offerCatalog.IOfferCatalog & { _id: string; alternateName?: any; dateSynced?: Date; } & Required<{ _id: string; }>>>; unsetUnnecessaryFields(params: { filter: FilterQuery<factory.offerCatalog.IOfferCatalog>; $unset: any; }): Promise<import("mongoose").UpdateWriteOpResult>; aggregateItemList(params: { itemListElement: { typeOf: { $eq: factory.offerType.Offer | 'OfferCatalog'; }; }; }): Promise<{ aggregation: any; }>; } export {};