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

Hierarchy (View Summary)

Properties

modelName: string

The name of the model.

Methods

  • Update an entity by its ID.

    Parameters

    • id: string

      The ID of the entity to update.

    • entity: PartialQuery<Job>

      The partial entity to update.

    • Optionaloptions: UpdateOptions

    Returns Promise<null | Saved<Job>>

    • A promise that resolves to the updated entity or null if not found.
  • Update a single entity matching the filter.

    Parameters

    • filter: FilterQuery<Job>

      The filter to match documents.

    • update: PartialQuery<Job>

      The partial update to apply.

    • Optionaloptions: UpdateOneOptions

      Options for updating a single document.

    Returns Promise<null | Saved<Job>>

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

      The filter to find the record to update or insert.

    • entity: PartialQuery<Job>

      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.