Order Repository
Provides a small in-memory repository for the order service example.
- Path
docs/examples/order_service/src/repository.gb- Category
- Order Service
Repositories isolate storage details from service code. This one uses a list so the example stays self-contained.
Source
module order_service.src.repository;
export class OrderRepository {
list<any> orders;
func OrderRepository() {
this.orders = [];
}
func add(any order): void {
this.orders = this.orders.push(order);
}
func all(): list<any> {
return this.orders;
}
}
export func newRepository(): OrderRepository {
return OrderRepository();
}