Skip to content

Commit

Permalink
enhance: add computed fields to gift-exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
bjardon committed Nov 28, 2024
1 parent a7fe5fb commit 54030c5
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/app/gift-exchanges/schemas/gift-exchange.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,26 @@ export class GiftExchangeEntity {
required: true,
})
_organizer: Types.ObjectId;

get formattedScheduledOn(): string {
return this.scheduledOn.toLocaleDateString('es-MX');
}

get formattedBudget(): string {
return Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
}).format(this.budget);
}
}

export const GiftExchangeSchema =
SchemaFactory.createForClass(GiftExchangeEntity);
const _GiftExchangeSchemaFactory = () => {
const schema = SchemaFactory.createForClass(GiftExchangeEntity);
schema.loadClass(GiftExchangeEntity);

return schema;
};

export const GiftExchangeSchema = _GiftExchangeSchemaFactory();

export type GiftExchangeDocument = HydratedDocument<GiftExchangeEntity>;

0 comments on commit 54030c5

Please sign in to comment.