Skip to content

Commit

Permalink
Add getAll method to TemplatesDataSource and MongoTemplatesDataSource…
Browse files Browse the repository at this point in the history
… for retrieving all templates
  • Loading branch information
Joao-vi committed Jan 29, 2025
1 parent 45db0cf commit 2e3449d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/api/templates.v2/contracts/TemplatesDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RelationshipProperty } from '../model/RelationshipProperty';
import { Template } from '../model/Template';

export interface TemplatesDataSource {
getAll(): ResultSet<Template>;
getAllTemplatesIds(): ResultSet<string>;
getAllRelationshipProperties(): ResultSet<RelationshipProperty>;
getAllProperties(): ResultSet<Property>;
Expand Down
4 changes: 4 additions & 0 deletions app/api/templates.v2/database/MongoTemplatesDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export class MongoTemplatesDataSource

private _nameToPropertyMap?: Record<string, Property>;

getAll() {
return new MongoResultSet(this.getCollection().find({}), TemplateMappers.toApp);
}

getAllRelationshipProperties() {
const cursor = this.getCollection().aggregate([
{
Expand Down

0 comments on commit 2e3449d

Please sign in to comment.