Skip to content

Commit

Permalink
perf: whispsCount uses mongo documentCount
Browse files Browse the repository at this point in the history
Previously used length of query results
  • Loading branch information
mestrak authored and David Wennemaring committed Nov 25, 2020
1 parent 1d112d5 commit 2e2a0d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/whisp/whisp.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class WhispResolver {
@Args('filter', { type: () => GraphQLJSONObject, nullable: true })
filter?: Record<string, unknown>,
) {
return (await this.whisps(filter)).length;
return this.whispService.countWhisps(filter);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/whisp/whisp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export class WhispService {
return this.whispModel.findById(id).exec();
}

async countWhisps(filter?: any): Promise<number> {
return this.whispModel.countDocuments(filter).exec();
}

async update(id: string, whispIn: any): Promise<IWhisp> {
const whisp = whispIn;
whisp.updated = new Date().toISOString();
Expand Down

0 comments on commit 2e2a0d5

Please sign in to comment.