interface EmailsRepository {
    modelName: string;
    countDocuments(query?: FilterQuery<Email>): Promise<number>;
    create(entity: Email): Promise<Saved<Email>>;
    createMany(entity: Email[], options?: CreateManyOptions): Promise<string[]>;
    deleteById(id: string): Promise<null | Saved<Email>>;
    destroyById(id: string): Promise<null | Saved<Email>>;
    findById(
        id: string,
        fields?: SelectQuery<Email>[],
        ListQueryOptions?: ListQueryOptions<Email>,
    ): Promise<null | Saved<Email>>;
    findEmailByEmailHookId(emailHookId: string): Promise<null | Email>;
    findOne(
        query?: FilterQuery<Email>,
        fields?: SelectQuery<Email>[],
        ListQueryOptions?: ListQueryOptions<Email>,
    ): Promise<null | Saved<Email>>;
    findPromoteLaunchEmail(): Promise<null | Email>;
    list(
        query?: FilterQuery<Email>,
        fields?: SelectQuery<Email>[],
        ListQueryOptions?: ListQueryOptions<Email>,
    ): Promise<Saved<Email>[]>;
    paginate(
        options?: PaginateQueryOptions<Email>,
    ): Promise<PaginationResponse<Saved<Email>>>;
    updateById(
        id: string,
        entity: PartialQuery<Email>,
        options?: UpdateOptions,
    ): Promise<null | Saved<Email>>;
    updateMany(
        filter: FilterQuery<Email>,
        update: PartialQuery<Email>,
    ): Promise<number>;
    updateOne(
        filter: FilterQuery<Email>,
        update: PartialQuery<Email>,
        options?: UpdateOneOptions,
    ): Promise<null | Saved<Email>>;
    upsertOne(
        filter: FilterQuery<Email>,
        entity: PartialQuery<Email>,
    ): Promise<null | string>;
}

Hierarchy (View Summary)

Properties

modelName: string

The name of the model.

Methods

  • Update a single entity matching the filter.

    Parameters

    • filter: FilterQuery<Email>

      The filter to match documents.

    • update: PartialQuery<Email>

      The partial update to apply.

    • Optionaloptions: UpdateOneOptions

      Options for updating a single document.

    Returns Promise<null | Saved<Email>>

    | null>} - A promise that resolves to the updated entity or null if not found.

  • Upsert a single record based on certain criteria.

    Parameters

    • filter: FilterQuery<Email>

      The filter to find the record to update or insert.

    • entity: PartialQuery<Email>

      The entity to upsert.

    Returns Promise<null | string>

    The return types of this method align with the MongoDB UpdateResult interface

    • Returns models.baseModel.Saved<T>['_id'] if the document did not exist (an upsert took place).
    • Returns null if the document did exist before the upsert operation.