UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

83 lines (82 loc) 2.22 kB
import type { Connection, FilterQuery } from 'mongoose'; import * as factory from '../factory'; import { IEmailMessage } from './mongoose/schemas/message'; type IFindByIdentifierResult = Pick<IEmailMessage, 'about' | 'identifier' | 'name' | 'sender' | 'text' | 'toRecipient' | 'typeOf'>; interface ISearchConditions { limit?: number; page?: number; sort?: { datePublished?: factory.sortType; }; project?: { id?: { $eq?: string; }; }; provider?: { id?: { $eq?: string; }; }; mainEntity?: { orderNumber?: { $eq?: string; }; }; identifier?: { $eq?: string; }; about?: { identifier?: { $eq?: string; }; }; } type IKeyOfProjection = keyof IEmailMessage; /** * メッセージリポジトリ */ export declare class MessageRepo { private readonly messageModel; constructor(connection: Connection); static CREATE_MONGO_CONDITIONS(params: ISearchConditions): FilterQuery<IEmailMessage>[]; /** * 検索 */ projectFields(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<(IEmailMessage & { id: string; })[]>; /** * コードをキーにしてなければ作成する(複数対応) */ /** * コードをキーにしてひとつ更新(なければ作成する) */ upsertOneByIdentifier(params: Pick<IEmailMessage, 'about' | 'identifier' | 'mainEntity' | 'name' | 'project' | 'sender' | 'text' | 'toRecipient' | 'provider'>): Promise<void>; /** * コードで参照 */ findByIdentifier(params: { identifier: string; project: { id: string; }; }): Promise<IFindByIdentifierResult>; deleteByMainEntityOrderNumber(params: { project: { id: string; }; mainEntity: { orderNumber: string; }; }): Promise<{ n?: number; ok?: number; deletedCount?: number; } | null>; unsetUnnecessaryFields(params: { filter: any; $unset: any; }): Promise<import("mongoose").UpdateWriteOpResult>; } export {};