Skip to content

Commit

Permalink
fix(query-repo): indexes options mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
lucagiove committed Dec 23, 2023
1 parent 4c28ba3 commit 299ab58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/mongo-aggregate-repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface IAggregateRepo<A> {
save: (aggregate: A) => Promise<void>;
}

type DocumentWithId = { id: string } & Document;
export type DocumentWithId = { id: string } & Document;

export type WithVersion<T> = T & { __version: number };

Expand Down
4 changes: 2 additions & 2 deletions src/mongo-query-repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface Logger {

export abstract class MongoQueryRepo<RM extends Document> {
protected readonly collection: Collection<RM>;
protected abstract readonly indexes: { indexSpec: IndexSpecification; options: CreateIndexesOptions }[];
protected abstract readonly indexes: { indexSpec: IndexSpecification; options?: CreateIndexesOptions }[];

protected constructor(
mongoClient: MongoClient,
Expand All @@ -25,7 +25,7 @@ export abstract class MongoQueryRepo<RM extends Document> {
if (!isEmpty(this.indexes)) {
for (const { indexSpec, options } of this.indexes) {
this.logger.log(`Creating index for ${JSON.stringify(indexSpec)} field.`);
await this.collection.createIndex(indexSpec, options);
await this.collection.createIndex(indexSpec, options || {});
}
}
}
Expand Down

0 comments on commit 299ab58

Please sign in to comment.