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

Hierarchy (View Summary)

Properties

modelName: string

The name of the model.

Methods

  • Upsert a single record based on certain criteria.

    Parameters

    • filter: FilterQuery<Category>

      The filter to find the record to update or insert.

    • entity: PartialQuery<Category>

      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.