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

      The filter to find the record to update or insert.

    • entity: PartialQuery<BaseList>

      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.