import { BaseModel } from "./base-model"; import { ChildModel, ChunkCallback, Document, Filter, PaginationListing, PrimaryIdType } from "./types"; export declare abstract class CrudModel extends BaseModel { /** * Create a new record in the database for the current model (child class of this one) * and return a new instance of it with the created data and the new generated id */ static create(this: ChildModel, data: Document): Promise; /** * Called before creating a new record */ protected beforeCreating(this: ChildModel, _data: Document): Promise; /** * Called after creating a new record */ protected onCreate(this: ChildModel): Promise; /** * Update model by the given id */ static update(this: ChildModel, id: PrimaryIdType, data: Document): Promise; /** * Replace the entire document for the given document id with the given new data */ static replace(this: ChildModel, id: PrimaryIdType, data: Document): Promise; /** * Restore the document from trash */ static restore(this: ChildModel, id: PrimaryIdType): Promise; /** * Restore all documents from trash or by the given filter */ static restoreAll(this: ChildModel, filter?: Filter): Promise; /** * Get deleted document by id */ static getDeleted(this: ChildModel, id: PrimaryIdType): Promise; /** * Get all deleted documents */ static getAllDeleted(this: ChildModel, filter?: Filter): Promise; /** * Find and update the document for the given filter with the given data or create a new document/record * if filter has no matching */ static upsert(this: ChildModel, filter: Filter, data: Document): Promise; /** * Find document by id */ static find(this: ChildModel, id: PrimaryIdType): Promise; /** * Find document by the given column and value */ static findBy(this: ChildModel, column: string, value: any): Promise; /** * Create an explain plan for the given filter */ static explain(this: ChildModel, filter?: Filter): Promise; /** * List multiple documents based on the given filter */ static list(this: ChildModel, filter?: Filter): Promise; /** * Paginate records based on the given filter */ static paginate(this: ChildModel, filter: Filter, page?: number, limit?: number): Promise>; /** * Count total documents based on the given filter */ static count(filter?: Filter): Promise; /** * Get first model for the given filter */ static first(this: ChildModel, filter?: Filter): Promise; /** * Get last model for the given filter */ static last(this: ChildModel, filter?: Filter): Promise; /** * Get latest documents */ static latest(this: ChildModel, filter?: Filter): Promise; /** * Delete single document if the given filter is an ObjectId of mongodb * Otherwise, delete multiple documents based on the given filter object */ static delete(this: ChildModel, filter?: PrimaryIdType | Filter): Promise; /** * Chunk the documents */ static chunk(this: ChildModel, limit: number, callback: ChunkCallback): Promise; static chunk(this: ChildModel, filter: Filter & { limit: number; }, callback: ChunkCallback): Promise; /** * Check if document exists for the given filter */ static exists(this: ChildModel, filter?: Filter): Promise; /** * Get distinct values for the given column */ static distinct(this: ChildModel, column: string, filter?: Filter): Promise; /** * Prepare filters */ protected static prepareFilters(filters?: Filter): Filter; } //# sourceMappingURL=crud-model.d.ts.map