Skip to content

Commit 69506a4

Browse files
bajtosraymondfeng
authored andcommitted
fix: clean up dataSource usage
Rename all "datasource" names to "dataSource" for consistency. Fix model-specific Repository classes to leverage "dataSource" property inherited from the base repository implementation instead of defining a new "datasource" property.
1 parent 4b90fb8 commit 69506a4

File tree

16 files changed

+31
-37
lines changed

16 files changed

+31
-37
lines changed

docs/site/Calling-other-APIs-and-Web-Services.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ import {GeocoderDataSource} from '../datasources/geocoder.datasource';
140140
export class GeoServiceProvider implements Provider<GeoService> {
141141
constructor(
142142
@inject('datasources.geoService')
143-
protected datasource: juggler.DataSource = new GeocoderDataSource(),
143+
protected dataSource: juggler.DataSource = new GeocoderDataSource(),
144144
) {}
145145

146146
value(): Promise<GeocoderService> {
147-
return getService(this.datasource);
147+
return getService(this.dataSource);
148148
}
149149
}
150150
```

docs/site/soap-calculator-tutorial-add-service.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ using **LB4** Dependency Injection.
120120
```ts
121121
constructor(
122122
@inject('datasources.calculator')
123-
protected datasource: juggler.DataSource = new CalculatorDataSource(),
123+
protected dataSource: juggler.DataSource = new CalculatorDataSource(),
124124
) {}
125125
```
126126

docs/site/todo-list-tutorial-repository.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ export class TodoListRepository extends DefaultCrudRepository<
5959
public todos: HasManyRepositoryFactory<Todo, typeof TodoList.prototype.id>;
6060

6161
constructor(
62-
@inject('datasources.db') protected datasource: juggler.DataSource,
62+
@inject('datasources.db') dataSource: juggler.DataSource,
6363
@repository(TodoRepository) protected todoRepository: TodoRepository,
6464
) {
65-
super(TodoList, datasource);
65+
super(TodoList, dataSource);
6666
this.todos = this._createHasManyRepositoryFactoryFor(
6767
'todos',
6868
todoRepository,

docs/site/todo-tutorial-geocoding-service.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ export interface GeocoderService {
125125
export class GeocoderServiceProvider implements Provider<GeocoderService> {
126126
constructor(
127127
@inject('datasources.geocoder')
128-
protected datasource: juggler.DataSource = new GeocoderDataSource(),
128+
protected dataSource: juggler.DataSource = new GeocoderDataSource(),
129129
) {}
130130

131131
value(): Promise<GeocoderService> {
132-
return getService(this.datasource);
132+
return getService(this.dataSource);
133133
}
134134
}
135135
```

docs/site/todo-tutorial-repository.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ export class TodoRepository extends DefaultCrudRepository<
7676
Todo,
7777
typeof Todo.prototype.id
7878
> {
79-
constructor(
80-
@inject('datasources.db') protected datasource: juggler.DataSource,
81-
) {
82-
super(Todo, datasource);
79+
constructor(@inject('datasources.db') dataSource: juggler.DataSource) {
80+
super(Todo, dataSource);
8381
}
8482
}
8583
```

examples/soap-calculator/src/services/calculator.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ export interface CalculatorService {
3737
export class CalculatorServiceProvider implements Provider<CalculatorService> {
3838
constructor(
3939
@inject('datasources.calculator')
40-
protected datasource: juggler.DataSource = new CalculatorDataSource(),
40+
protected dataSource: juggler.DataSource = new CalculatorDataSource(),
4141
) {}
4242

4343
value(): Promise<CalculatorService> {
44-
return getService(this.datasource);
44+
return getService(this.dataSource);
4545
}
4646
}

examples/todo-list/src/repositories/todo-list.repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ export class TodoListRepository extends DefaultCrudRepository<
2020
public todos: HasManyRepositoryFactory<Todo, typeof TodoList.prototype.id>;
2121

2222
constructor(
23-
@inject('datasources.db') protected datasource: juggler.DataSource,
23+
@inject('datasources.db') dataSource: juggler.DataSource,
2424
@repository.getter(TodoRepository)
2525
protected todoRepositoryGetter: Getter<TodoRepository>,
2626
) {
27-
super(TodoList, datasource);
27+
super(TodoList, dataSource);
2828
this.todos = this._createHasManyRepositoryFactoryFor(
2929
'todos',
3030
todoRepositoryGetter,

examples/todo-list/src/repositories/todo.repository.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ export class TodoRepository extends DefaultCrudRepository<
1111
Todo,
1212
typeof Todo.prototype.id
1313
> {
14-
constructor(
15-
@inject('datasources.db') protected datasource: juggler.DataSource,
16-
) {
17-
super(Todo, datasource);
14+
constructor(@inject('datasources.db') dataSource: juggler.DataSource) {
15+
super(Todo, dataSource);
1816
}
1917
}

examples/todo/src/repositories/todo.repository.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ export class TodoRepository extends DefaultCrudRepository<
1111
Todo,
1212
typeof Todo.prototype.id
1313
> {
14-
constructor(
15-
@inject('datasources.db') protected datasource: juggler.DataSource,
16-
) {
17-
super(Todo, datasource);
14+
constructor(@inject('datasources.db') dataSource: juggler.DataSource) {
15+
super(Todo, dataSource);
1816
}
1917
}

examples/todo/src/services/geocoder.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ export interface GeocoderService {
2626
export class GeocoderServiceProvider implements Provider<GeocoderService> {
2727
constructor(
2828
@inject('datasources.geocoder')
29-
protected datasource: juggler.DataSource = new GeocoderDataSource(),
29+
protected dataSource: juggler.DataSource = new GeocoderDataSource(),
3030
) {}
3131

3232
value(): Promise<GeocoderService> {
33-
return getService(this.datasource);
33+
return getService(this.dataSource);
3434
}
3535
}

0 commit comments

Comments
 (0)