interface ReviewsRepository {
    modelName: string;
    countDocuments(query?: FilterQuery<Review>): Promise<number>;
    create(entity: Review): Promise<Saved<Review>>;
    createMany(
        entity: Review[],
        options?: CreateManyOptions,
    ): Promise<string[]>;
    deleteById(id: string): Promise<null | Saved<Review>>;
    destroyById(id: string): Promise<null | Saved<Review>>;
    findByEndorsalId(endorsalId: string): Promise<null | SavedReview>;
    findById(
        id: string,
        fields?: SelectQuery<Review>[],
        ListQueryOptions?: ListQueryOptions<Review>,
    ): Promise<null | Saved<Review>>;
    findOne(
        query?: FilterQuery<Review>,
        fields?: SelectQuery<Review>[],
        ListQueryOptions?: ListQueryOptions<Review>,
    ): Promise<null | Saved<Review>>;
    list(
        query?: FilterQuery<Review>,
        fields?: SelectQuery<Review>[],
        ListQueryOptions?: ListQueryOptions<Review>,
    ): Promise<Saved<Review>[]>;
    paginate(
        options?: PaginateQueryOptions<Review>,
    ): Promise<PaginationResponse<Saved<Review>>>;
    updateById(
        id: string,
        entity: PartialQuery<Review>,
        options?: UpdateOptions,
    ): Promise<null | Saved<Review>>;
    updateMany(
        filter: FilterQuery<Review>,
        update: PartialQuery<Review>,
    ): Promise<number>;
    updateOne(
        filter: FilterQuery<Review>,
        update: PartialQuery<Review>,
        options?: UpdateOneOptions,
    ): Promise<null | Saved<Review>>;
    upsertOne(
        filter: FilterQuery<Review>,
        entity: PartialQuery<Review>,
    ): 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<Review>

      The filter to match documents.

    • update: PartialQuery<Review>

      The partial update to apply.

    • Optionaloptions: UpdateOneOptions

      Options for updating a single document.

    Returns Promise<null | Saved<Review>>

    | 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<Review>

      The filter to find the record to update or insert.

    • entity: PartialQuery<Review>

      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.