Skip to content

Commit

Permalink
fix: mark HasManyRepository as a readonly property
Browse files Browse the repository at this point in the history
  • Loading branch information
bajtos committed Oct 5, 2018
1 parent 942e523 commit 39227eb
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 9 deletions.
5 changes: 4 additions & 1 deletion docs/site/HasMany-relation.md
Expand Up @@ -131,7 +131,10 @@ class CustomerRepository extends DefaultCrudRepository<
Customer,
typeof Customer.prototype.id
> {
public orders: HasManyRepositoryFactory<Order, typeof Customer.prototype.id>;
public readonly orders: HasManyRepositoryFactory<
Order,
typeof Customer.prototype.id
>;
constructor(
@inject('datasources.db') protected db: juggler.DataSource,
@repository.getter(OrderRepository)
Expand Down
5 changes: 4 additions & 1 deletion docs/site/todo-list-tutorial-repository.md
Expand Up @@ -56,7 +56,10 @@ export class TodoListRepository extends DefaultCrudRepository<
TodoList,
typeof TodoList.prototype.id
> {
public todos: HasManyRepositoryFactory<Todo, typeof TodoList.prototype.id>;
public readonly todos: HasManyRepositoryFactory<
Todo,
typeof TodoList.prototype.id
>;

constructor(
@inject('datasources.db') dataSource: juggler.DataSource,
Expand Down
5 changes: 4 additions & 1 deletion examples/todo-list/src/repositories/todo-list.repository.ts
Expand Up @@ -17,7 +17,10 @@ export class TodoListRepository extends DefaultCrudRepository<
TodoList,
typeof TodoList.prototype.id
> {
public todos: HasManyRepositoryFactory<Todo, typeof TodoList.prototype.id>;
public readonly todos: HasManyRepositoryFactory<
Todo,
typeof TodoList.prototype.id
>;

constructor(
@inject('datasources.db') dataSource: juggler.DataSource,
Expand Down
5 changes: 4 additions & 1 deletion examples/todo-list/src/repositories/todo.repository.ts
Expand Up @@ -17,7 +17,10 @@ export class TodoRepository extends DefaultCrudRepository<
Todo,
typeof Todo.prototype.id
> {
public todoList: BelongsToAccessor<TodoList, typeof Todo.prototype.id>;
public readonly todoList: BelongsToAccessor<
TodoList,
typeof Todo.prototype.id
>;

constructor(
@inject('datasources.db') dataSource: juggler.DataSource,
Expand Down
Expand Up @@ -150,7 +150,9 @@ describe('TodoController', () => {
.stub()
.withArgs(aTodoListWithId.id!)
.returns(constrainedTodoRepo);
todoListRepo.todos = todos;

// tslint:disable-next-line:no-any
(todoListRepo as any).todos = todos;

// Setup CRUD fakes
({create, find, patch, delete: del} = constrainedTodoRepo.stubs);
Expand Down
Expand Up @@ -151,7 +151,7 @@ export class DefaultCrudRepository<T extends Entity, ID>
* Customer,
* typeof Customer.prototype.id
* > {
* public orders: HasManyRepositoryFactory<Order, typeof Customer.prototype.id>;
* public readonly orders: HasManyRepositoryFactory<Order, typeof Customer.prototype.id>;
*
* constructor(
* protected db: juggler.DataSource,
Expand Down
Expand Up @@ -132,7 +132,7 @@ describe('HasMany relation', () => {
Customer,
typeof Customer.prototype.id
> {
public orders: HasManyRepositoryFactory<
public readonly orders: HasManyRepositoryFactory<
Order,
typeof Customer.prototype.id
>;
Expand Down
Expand Up @@ -17,7 +17,10 @@ export class CustomerRepository extends DefaultCrudRepository<
Customer,
typeof Customer.prototype.id
> {
public orders: HasManyRepositoryFactory<Order, typeof Customer.prototype.id>;
public readonly orders: HasManyRepositoryFactory<
Order,
typeof Customer.prototype.id
>;
constructor(
@inject('datasources.db') protected db: juggler.DataSource,
@repository.getter('OrderRepository')
Expand Down
Expand Up @@ -17,7 +17,10 @@ export class OrderRepository extends DefaultCrudRepository<
Order,
typeof Order.prototype.id
> {
public customer: BelongsToAccessor<Customer, typeof Order.prototype.id>;
public readonly customer: BelongsToAccessor<
Customer,
typeof Order.prototype.id
>;

constructor(
@inject('datasources.db') protected db: juggler.DataSource,
Expand Down

0 comments on commit 39227eb

Please sign in to comment.