Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions CHANGELOG.md

This file was deleted.

23 changes: 15 additions & 8 deletions src/repositories/base.repository.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
type FilterQuery,
type HydratedDocument,
type LeanDocument,
type Model,
type PopulateOptions,
type ProjectionType,
type QueryOptions,
type UpdateQuery,
FilterQuery,
HydratedDocument,
LeanDocument,
Model,
PopulateOptions,
ProjectionType,
QueryOptions,
UpdateQuery,
} from 'mongoose';

export interface PaginateOptions {
Expand Down Expand Up @@ -63,6 +63,13 @@ export class BaseRepository<T> {
return await this.model.updateOne(filter, update, options);
}

async upsert(filter: FilterQuery<T>, update: UpdateQuery<T>, options?: QueryOptions): Promise<any> {
return await this.model.updateOne(filter, update, {
...options,
upsert: true,
});
}

async deleteOne(filter: FilterQuery<T>): Promise<any> {
return await this.model.deleteOne(filter);
}
Expand Down