@loopback/sequelize 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/sequelize/sequelize.datasource.base.d.ts +1 -1
  2. package/dist/sequelize/sequelize.datasource.base.js +2 -3
  3. package/dist/sequelize/sequelize.datasource.base.js.map +1 -1
  4. package/dist/sequelize/sequelize.repository.base.d.ts +19 -4
  5. package/dist/sequelize/sequelize.repository.base.js +26 -6
  6. package/dist/sequelize/sequelize.repository.base.js.map +1 -1
  7. package/dist/sequelize/utils.d.ts +8 -0
  8. package/dist/sequelize/utils.js +21 -1
  9. package/dist/sequelize/utils.js.map +1 -1
  10. package/package.json +13 -11
  11. package/src/sequelize/sequelize.datasource.base.ts +4 -5
  12. package/src/sequelize/sequelize.repository.base.ts +58 -14
  13. package/src/sequelize/utils.ts +18 -0
  14. package/dist/.sandbox/23319CTsyje/application.js +0 -15
  15. package/dist/.sandbox/23319CTsyje/controllers/book-category.controller.js +0 -41
  16. package/dist/.sandbox/23319CTsyje/controllers/book.controller.js +0 -210
  17. package/dist/.sandbox/23319CTsyje/controllers/category.controller.js +0 -198
  18. package/dist/.sandbox/23319CTsyje/controllers/developer.controller.js +0 -177
  19. package/dist/.sandbox/23319CTsyje/controllers/doctor-patient.controller.js +0 -112
  20. package/dist/.sandbox/23319CTsyje/controllers/doctor.controller.js +0 -177
  21. package/dist/.sandbox/23319CTsyje/controllers/index.js +0 -23
  22. package/dist/.sandbox/23319CTsyje/controllers/patient.controller.js +0 -165
  23. package/dist/.sandbox/23319CTsyje/controllers/product.controller.js +0 -177
  24. package/dist/.sandbox/23319CTsyje/controllers/programming-languange.controller.js +0 -204
  25. package/dist/.sandbox/23319CTsyje/controllers/task.controller.js +0 -210
  26. package/dist/.sandbox/23319CTsyje/controllers/test.controller.base.js +0 -27
  27. package/dist/.sandbox/23319CTsyje/controllers/todo-list-todo.controller.js +0 -113
  28. package/dist/.sandbox/23319CTsyje/controllers/todo-list.controller.js +0 -177
  29. package/dist/.sandbox/23319CTsyje/controllers/todo-todo-list.controller.js +0 -41
  30. package/dist/.sandbox/23319CTsyje/controllers/todo.controller.js +0 -177
  31. package/dist/.sandbox/23319CTsyje/controllers/transaction.controller.js +0 -157
  32. package/dist/.sandbox/23319CTsyje/controllers/user-todo-list.controller.js +0 -113
  33. package/dist/.sandbox/23319CTsyje/controllers/user.controller.js +0 -210
  34. package/dist/.sandbox/23319CTsyje/datasources/config.js +0 -65
  35. package/dist/.sandbox/23319CTsyje/datasources/primary.datasource.js +0 -28
  36. package/dist/.sandbox/23319CTsyje/datasources/secondary.datasource.js +0 -28
  37. package/dist/.sandbox/23319CTsyje/models/appointment.model.js +0 -37
  38. package/dist/.sandbox/23319CTsyje/models/book.model.js +0 -48
  39. package/dist/.sandbox/23319CTsyje/models/category.model.js +0 -32
  40. package/dist/.sandbox/23319CTsyje/models/developer.model.js +0 -47
  41. package/dist/.sandbox/23319CTsyje/models/doctor.model.js +0 -44
  42. package/dist/.sandbox/23319CTsyje/models/index.js +0 -17
  43. package/dist/.sandbox/23319CTsyje/models/patient.model.js +0 -32
  44. package/dist/.sandbox/23319CTsyje/models/product.model.js +0 -41
  45. package/dist/.sandbox/23319CTsyje/models/programming-language.model.js +0 -39
  46. package/dist/.sandbox/23319CTsyje/models/task.model.js +0 -74
  47. package/dist/.sandbox/23319CTsyje/models/todo-list.model.js +0 -45
  48. package/dist/.sandbox/23319CTsyje/models/todo.model.js +0 -44
  49. package/dist/.sandbox/23319CTsyje/models/user.model.js +0 -92
  50. package/dist/.sandbox/23319CTsyje/repositories/appointment.repository.js +0 -20
  51. package/dist/.sandbox/23319CTsyje/repositories/book.repository.js +0 -25
  52. package/dist/.sandbox/23319CTsyje/repositories/category.repository.js +0 -20
  53. package/dist/.sandbox/23319CTsyje/repositories/developer.repository.js +0 -25
  54. package/dist/.sandbox/23319CTsyje/repositories/doctor.repository.js +0 -27
  55. package/dist/.sandbox/23319CTsyje/repositories/index.js +0 -17
  56. package/dist/.sandbox/23319CTsyje/repositories/patient.repository.js +0 -20
  57. package/dist/.sandbox/23319CTsyje/repositories/product.repository.js +0 -20
  58. package/dist/.sandbox/23319CTsyje/repositories/programming-language.repository.js +0 -20
  59. package/dist/.sandbox/23319CTsyje/repositories/task.repository.js +0 -26
  60. package/dist/.sandbox/23319CTsyje/repositories/todo-list.repository.js +0 -25
  61. package/dist/.sandbox/23319CTsyje/repositories/todo.repository.js +0 -25
  62. package/dist/.sandbox/23319CTsyje/repositories/user.repository.js +0 -25
@@ -1,177 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TodoListController = void 0;
4
- const tslib_1 = require("tslib");
5
- const repository_1 = require("@loopback/repository");
6
- const rest_1 = require("@loopback/rest");
7
- const models_1 = require("../models");
8
- const repositories_1 = require("../repositories");
9
- const test_controller_base_1 = require("./test.controller.base");
10
- let TodoListController = class TodoListController extends test_controller_base_1.TestControllerBase {
11
- constructor(todoListRepository) {
12
- super(todoListRepository);
13
- this.todoListRepository = todoListRepository;
14
- }
15
- async create(todoList) {
16
- return this.todoListRepository.create(todoList);
17
- }
18
- async count(where) {
19
- return this.todoListRepository.count(where);
20
- }
21
- async find(filter) {
22
- return this.todoListRepository.find(filter);
23
- }
24
- async updateAll(todoList, where) {
25
- return this.todoListRepository.updateAll(todoList, where);
26
- }
27
- async findById(id, filter) {
28
- return this.todoListRepository.findById(id, filter);
29
- }
30
- async updateById(id, todoList) {
31
- await this.todoListRepository.updateById(id, todoList);
32
- }
33
- async replaceById(id, todoList) {
34
- await this.todoListRepository.replaceById(id, todoList);
35
- }
36
- async deleteById(id) {
37
- await this.todoListRepository.deleteById(id);
38
- }
39
- async syncSequelizeModel() {
40
- await this.beforeEach({ syncAll: true });
41
- }
42
- };
43
- exports.TodoListController = TodoListController;
44
- tslib_1.__decorate([
45
- (0, rest_1.post)('/todo-lists'),
46
- (0, rest_1.response)(200, {
47
- description: 'TodoList model instance',
48
- content: { 'application/json': { schema: (0, rest_1.getModelSchemaRef)(models_1.TodoList) } },
49
- }),
50
- tslib_1.__param(0, (0, rest_1.requestBody)({
51
- content: {
52
- 'application/json': {
53
- schema: (0, rest_1.getModelSchemaRef)(models_1.TodoList, {
54
- title: 'NewTodoList',
55
- exclude: ['id'],
56
- }),
57
- },
58
- },
59
- })),
60
- tslib_1.__metadata("design:type", Function),
61
- tslib_1.__metadata("design:paramtypes", [Object]),
62
- tslib_1.__metadata("design:returntype", Promise)
63
- ], TodoListController.prototype, "create", null);
64
- tslib_1.__decorate([
65
- (0, rest_1.get)('/todo-lists/count'),
66
- (0, rest_1.response)(200, {
67
- description: 'TodoList model count',
68
- content: { 'application/json': { schema: repository_1.CountSchema } },
69
- }),
70
- tslib_1.__param(0, rest_1.param.where(models_1.TodoList)),
71
- tslib_1.__metadata("design:type", Function),
72
- tslib_1.__metadata("design:paramtypes", [Object]),
73
- tslib_1.__metadata("design:returntype", Promise)
74
- ], TodoListController.prototype, "count", null);
75
- tslib_1.__decorate([
76
- (0, rest_1.get)('/todo-lists'),
77
- (0, rest_1.response)(200, {
78
- description: 'Array of TodoList model instances',
79
- content: {
80
- 'application/json': {
81
- schema: {
82
- type: 'array',
83
- items: (0, rest_1.getModelSchemaRef)(models_1.TodoList, { includeRelations: true }),
84
- },
85
- },
86
- },
87
- }),
88
- tslib_1.__param(0, rest_1.param.filter(models_1.TodoList)),
89
- tslib_1.__metadata("design:type", Function),
90
- tslib_1.__metadata("design:paramtypes", [Object]),
91
- tslib_1.__metadata("design:returntype", Promise)
92
- ], TodoListController.prototype, "find", null);
93
- tslib_1.__decorate([
94
- (0, rest_1.patch)('/todo-lists'),
95
- (0, rest_1.response)(200, {
96
- description: 'TodoList PATCH success count',
97
- content: { 'application/json': { schema: repository_1.CountSchema } },
98
- }),
99
- tslib_1.__param(0, (0, rest_1.requestBody)({
100
- content: {
101
- 'application/json': {
102
- schema: (0, rest_1.getModelSchemaRef)(models_1.TodoList, { partial: true }),
103
- },
104
- },
105
- })),
106
- tslib_1.__param(1, rest_1.param.where(models_1.TodoList)),
107
- tslib_1.__metadata("design:type", Function),
108
- tslib_1.__metadata("design:paramtypes", [models_1.TodoList, Object]),
109
- tslib_1.__metadata("design:returntype", Promise)
110
- ], TodoListController.prototype, "updateAll", null);
111
- tslib_1.__decorate([
112
- (0, rest_1.get)('/todo-lists/{id}'),
113
- (0, rest_1.response)(200, {
114
- description: 'TodoList model instance',
115
- content: {
116
- 'application/json': {
117
- schema: (0, rest_1.getModelSchemaRef)(models_1.TodoList, { includeRelations: true }),
118
- },
119
- },
120
- }),
121
- tslib_1.__param(0, rest_1.param.path.number('id')),
122
- tslib_1.__param(1, rest_1.param.filter(models_1.TodoList, { exclude: 'where' })),
123
- tslib_1.__metadata("design:type", Function),
124
- tslib_1.__metadata("design:paramtypes", [Number, Object]),
125
- tslib_1.__metadata("design:returntype", Promise)
126
- ], TodoListController.prototype, "findById", null);
127
- tslib_1.__decorate([
128
- (0, rest_1.patch)('/todo-lists/{id}'),
129
- (0, rest_1.response)(204, {
130
- description: 'TodoList PATCH success',
131
- }),
132
- tslib_1.__param(0, rest_1.param.path.number('id')),
133
- tslib_1.__param(1, (0, rest_1.requestBody)({
134
- content: {
135
- 'application/json': {
136
- schema: (0, rest_1.getModelSchemaRef)(models_1.TodoList, { partial: true }),
137
- },
138
- },
139
- })),
140
- tslib_1.__metadata("design:type", Function),
141
- tslib_1.__metadata("design:paramtypes", [Number, models_1.TodoList]),
142
- tslib_1.__metadata("design:returntype", Promise)
143
- ], TodoListController.prototype, "updateById", null);
144
- tslib_1.__decorate([
145
- (0, rest_1.put)('/todo-lists/{id}'),
146
- (0, rest_1.response)(204, {
147
- description: 'TodoList PUT success',
148
- }),
149
- tslib_1.__param(0, rest_1.param.path.number('id')),
150
- tslib_1.__param(1, (0, rest_1.requestBody)()),
151
- tslib_1.__metadata("design:type", Function),
152
- tslib_1.__metadata("design:paramtypes", [Number, models_1.TodoList]),
153
- tslib_1.__metadata("design:returntype", Promise)
154
- ], TodoListController.prototype, "replaceById", null);
155
- tslib_1.__decorate([
156
- (0, rest_1.del)('/todo-lists/{id}'),
157
- (0, rest_1.response)(204, {
158
- description: 'TodoList DELETE success',
159
- }),
160
- tslib_1.__param(0, rest_1.param.path.number('id')),
161
- tslib_1.__metadata("design:type", Function),
162
- tslib_1.__metadata("design:paramtypes", [Number]),
163
- tslib_1.__metadata("design:returntype", Promise)
164
- ], TodoListController.prototype, "deleteById", null);
165
- tslib_1.__decorate([
166
- (0, rest_1.get)('/todo-lists/sync-sequelize-model'),
167
- (0, rest_1.response)(200),
168
- tslib_1.__metadata("design:type", Function),
169
- tslib_1.__metadata("design:paramtypes", []),
170
- tslib_1.__metadata("design:returntype", Promise)
171
- ], TodoListController.prototype, "syncSequelizeModel", null);
172
- exports.TodoListController = TodoListController = tslib_1.__decorate([
173
- tslib_1.__param(0, (0, repository_1.repository)(repositories_1.TodoListRepository)),
174
- tslib_1.__metadata("design:paramtypes", [repositories_1.TodoListRepository])
175
- ], TodoListController);
176
- //# sourceMappingURL=todo-list.controller.js.map
177
- //# sourceMappingURL=/Users/dianalau/code/loopback/loopback-next/extensions/sequelize/dist/__tests__/fixtures/controllers/todo-list.controller.js.map
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TodoTodoListController = void 0;
4
- const tslib_1 = require("tslib");
5
- const repository_1 = require("@loopback/repository");
6
- const rest_1 = require("@loopback/rest");
7
- const models_1 = require("../models");
8
- const repositories_1 = require("../repositories");
9
- let TodoTodoListController = class TodoTodoListController {
10
- constructor(todoRepository) {
11
- this.todoRepository = todoRepository;
12
- }
13
- async getTodoList(id) {
14
- return this.todoRepository.todoList(id);
15
- }
16
- };
17
- exports.TodoTodoListController = TodoTodoListController;
18
- tslib_1.__decorate([
19
- (0, rest_1.get)('/todos/{id}/todo-list', {
20
- responses: {
21
- '200': {
22
- description: 'TodoList belonging to Todo',
23
- content: {
24
- 'application/json': {
25
- schema: { type: 'array', items: (0, rest_1.getModelSchemaRef)(models_1.TodoList) },
26
- },
27
- },
28
- },
29
- },
30
- }),
31
- tslib_1.__param(0, rest_1.param.path.number('id')),
32
- tslib_1.__metadata("design:type", Function),
33
- tslib_1.__metadata("design:paramtypes", [Object]),
34
- tslib_1.__metadata("design:returntype", Promise)
35
- ], TodoTodoListController.prototype, "getTodoList", null);
36
- exports.TodoTodoListController = TodoTodoListController = tslib_1.__decorate([
37
- tslib_1.__param(0, (0, repository_1.repository)(repositories_1.TodoRepository)),
38
- tslib_1.__metadata("design:paramtypes", [repositories_1.TodoRepository])
39
- ], TodoTodoListController);
40
- //# sourceMappingURL=todo-todo-list.controller.js.map
41
- //# sourceMappingURL=/Users/dianalau/code/loopback/loopback-next/extensions/sequelize/dist/__tests__/fixtures/controllers/todo-todo-list.controller.js.map
@@ -1,177 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TodoController = void 0;
4
- const tslib_1 = require("tslib");
5
- const repository_1 = require("@loopback/repository");
6
- const rest_1 = require("@loopback/rest");
7
- const models_1 = require("../models");
8
- const repositories_1 = require("../repositories");
9
- const test_controller_base_1 = require("./test.controller.base");
10
- let TodoController = class TodoController extends test_controller_base_1.TestControllerBase {
11
- constructor(todoRepository) {
12
- super(todoRepository);
13
- this.todoRepository = todoRepository;
14
- }
15
- async create(todo) {
16
- return this.todoRepository.create(todo);
17
- }
18
- async count(where) {
19
- return this.todoRepository.count(where);
20
- }
21
- async find(filter) {
22
- return this.todoRepository.find(filter);
23
- }
24
- async updateAll(todo, where) {
25
- return this.todoRepository.updateAll(todo, where);
26
- }
27
- async findById(id, filter) {
28
- return this.todoRepository.findById(id, filter);
29
- }
30
- async updateById(id, todo) {
31
- await this.todoRepository.updateById(id, todo);
32
- }
33
- async replaceById(id, todo) {
34
- await this.todoRepository.replaceById(id, todo);
35
- }
36
- async deleteById(id) {
37
- await this.todoRepository.deleteById(id);
38
- }
39
- async syncSequelizeModel() {
40
- await this.beforeEach();
41
- }
42
- };
43
- exports.TodoController = TodoController;
44
- tslib_1.__decorate([
45
- (0, rest_1.post)('/todos'),
46
- (0, rest_1.response)(200, {
47
- description: 'Todo model instance',
48
- content: { 'application/json': { schema: (0, rest_1.getModelSchemaRef)(models_1.Todo) } },
49
- }),
50
- tslib_1.__param(0, (0, rest_1.requestBody)({
51
- content: {
52
- 'application/json': {
53
- schema: (0, rest_1.getModelSchemaRef)(models_1.Todo, {
54
- title: 'NewTodo',
55
- exclude: ['id'],
56
- }),
57
- },
58
- },
59
- })),
60
- tslib_1.__metadata("design:type", Function),
61
- tslib_1.__metadata("design:paramtypes", [Object]),
62
- tslib_1.__metadata("design:returntype", Promise)
63
- ], TodoController.prototype, "create", null);
64
- tslib_1.__decorate([
65
- (0, rest_1.get)('/todos/count'),
66
- (0, rest_1.response)(200, {
67
- description: 'Todo model count',
68
- content: { 'application/json': { schema: repository_1.CountSchema } },
69
- }),
70
- tslib_1.__param(0, rest_1.param.where(models_1.Todo)),
71
- tslib_1.__metadata("design:type", Function),
72
- tslib_1.__metadata("design:paramtypes", [Object]),
73
- tslib_1.__metadata("design:returntype", Promise)
74
- ], TodoController.prototype, "count", null);
75
- tslib_1.__decorate([
76
- (0, rest_1.get)('/todos'),
77
- (0, rest_1.response)(200, {
78
- description: 'Array of Todo model instances',
79
- content: {
80
- 'application/json': {
81
- schema: {
82
- type: 'array',
83
- items: (0, rest_1.getModelSchemaRef)(models_1.Todo, { includeRelations: true }),
84
- },
85
- },
86
- },
87
- }),
88
- tslib_1.__param(0, rest_1.param.filter(models_1.Todo)),
89
- tslib_1.__metadata("design:type", Function),
90
- tslib_1.__metadata("design:paramtypes", [Object]),
91
- tslib_1.__metadata("design:returntype", Promise)
92
- ], TodoController.prototype, "find", null);
93
- tslib_1.__decorate([
94
- (0, rest_1.patch)('/todos'),
95
- (0, rest_1.response)(200, {
96
- description: 'Todo PATCH success count',
97
- content: { 'application/json': { schema: repository_1.CountSchema } },
98
- }),
99
- tslib_1.__param(0, (0, rest_1.requestBody)({
100
- content: {
101
- 'application/json': {
102
- schema: (0, rest_1.getModelSchemaRef)(models_1.Todo, { partial: true }),
103
- },
104
- },
105
- })),
106
- tslib_1.__param(1, rest_1.param.where(models_1.Todo)),
107
- tslib_1.__metadata("design:type", Function),
108
- tslib_1.__metadata("design:paramtypes", [models_1.Todo, Object]),
109
- tslib_1.__metadata("design:returntype", Promise)
110
- ], TodoController.prototype, "updateAll", null);
111
- tslib_1.__decorate([
112
- (0, rest_1.get)('/todos/{id}'),
113
- (0, rest_1.response)(200, {
114
- description: 'Todo model instance',
115
- content: {
116
- 'application/json': {
117
- schema: (0, rest_1.getModelSchemaRef)(models_1.Todo, { includeRelations: true }),
118
- },
119
- },
120
- }),
121
- tslib_1.__param(0, rest_1.param.path.number('id')),
122
- tslib_1.__param(1, rest_1.param.filter(models_1.Todo, { exclude: 'where' })),
123
- tslib_1.__metadata("design:type", Function),
124
- tslib_1.__metadata("design:paramtypes", [Number, Object]),
125
- tslib_1.__metadata("design:returntype", Promise)
126
- ], TodoController.prototype, "findById", null);
127
- tslib_1.__decorate([
128
- (0, rest_1.patch)('/todos/{id}'),
129
- (0, rest_1.response)(204, {
130
- description: 'Todo PATCH success',
131
- }),
132
- tslib_1.__param(0, rest_1.param.path.number('id')),
133
- tslib_1.__param(1, (0, rest_1.requestBody)({
134
- content: {
135
- 'application/json': {
136
- schema: (0, rest_1.getModelSchemaRef)(models_1.Todo, { partial: true }),
137
- },
138
- },
139
- })),
140
- tslib_1.__metadata("design:type", Function),
141
- tslib_1.__metadata("design:paramtypes", [Number, models_1.Todo]),
142
- tslib_1.__metadata("design:returntype", Promise)
143
- ], TodoController.prototype, "updateById", null);
144
- tslib_1.__decorate([
145
- (0, rest_1.put)('/todos/{id}'),
146
- (0, rest_1.response)(204, {
147
- description: 'Todo PUT success',
148
- }),
149
- tslib_1.__param(0, rest_1.param.path.number('id')),
150
- tslib_1.__param(1, (0, rest_1.requestBody)()),
151
- tslib_1.__metadata("design:type", Function),
152
- tslib_1.__metadata("design:paramtypes", [Number, models_1.Todo]),
153
- tslib_1.__metadata("design:returntype", Promise)
154
- ], TodoController.prototype, "replaceById", null);
155
- tslib_1.__decorate([
156
- (0, rest_1.del)('/todos/{id}'),
157
- (0, rest_1.response)(204, {
158
- description: 'Todo DELETE success',
159
- }),
160
- tslib_1.__param(0, rest_1.param.path.number('id')),
161
- tslib_1.__metadata("design:type", Function),
162
- tslib_1.__metadata("design:paramtypes", [Number]),
163
- tslib_1.__metadata("design:returntype", Promise)
164
- ], TodoController.prototype, "deleteById", null);
165
- tslib_1.__decorate([
166
- (0, rest_1.get)('/todos/sync-sequelize-model'),
167
- (0, rest_1.response)(200),
168
- tslib_1.__metadata("design:type", Function),
169
- tslib_1.__metadata("design:paramtypes", []),
170
- tslib_1.__metadata("design:returntype", Promise)
171
- ], TodoController.prototype, "syncSequelizeModel", null);
172
- exports.TodoController = TodoController = tslib_1.__decorate([
173
- tslib_1.__param(0, (0, repository_1.repository)(repositories_1.TodoRepository)),
174
- tslib_1.__metadata("design:paramtypes", [repositories_1.TodoRepository])
175
- ], TodoController);
176
- //# sourceMappingURL=todo.controller.js.map
177
- //# sourceMappingURL=/Users/dianalau/code/loopback/loopback-next/extensions/sequelize/dist/__tests__/fixtures/controllers/todo.controller.js.map
@@ -1,157 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TransactionController = void 0;
4
- const tslib_1 = require("tslib");
5
- const repository_1 = require("@loopback/repository");
6
- const rest_1 = require("@loopback/rest");
7
- const models_1 = require("../models");
8
- const repositories_1 = require("../repositories");
9
- const types_1 = require("./../../../types");
10
- const test_controller_base_1 = require("./test.controller.base");
11
- let TransactionController = class TransactionController extends test_controller_base_1.TestControllerBase {
12
- constructor(todoListRepository, productRepository) {
13
- super(todoListRepository, productRepository);
14
- this.todoListRepository = todoListRepository;
15
- this.productRepository = productRepository;
16
- }
17
- // create todo-list entry using transaction
18
- async ensureTransactionCommit(todoList) {
19
- const tx = await this.todoListRepository.beginTransaction({
20
- isolationLevel: types_1.Transaction.ISOLATION_LEVELS.SERIALIZABLE,
21
- });
22
- try {
23
- const created = await this.todoListRepository.create(todoList, {
24
- transaction: tx,
25
- });
26
- await tx.commit();
27
- return created;
28
- }
29
- catch (err) {
30
- await tx.rollback();
31
- throw err;
32
- }
33
- }
34
- // create todo-list entry using transaction but rollback
35
- async ensureRollback(todoList) {
36
- const tx = await this.todoListRepository.beginTransaction({
37
- isolationLevel: types_1.Transaction.ISOLATION_LEVELS.READ_COMMITTED,
38
- });
39
- const created = await this.todoListRepository.create(todoList, {
40
- transaction: tx,
41
- });
42
- await tx.rollback();
43
- // In real applications if you're rolling back. Don't return created entities to user
44
- // For test cases it's required here. (to get the id)
45
- return created;
46
- }
47
- // create todo-list entry using transaction but don't commit or rollback
48
- async ensureIsolatedTransaction(todoList) {
49
- const tx = await this.todoListRepository.beginTransaction({
50
- isolationLevel: types_1.Transaction.ISOLATION_LEVELS.READ_COMMITTED,
51
- });
52
- const created = await this.todoListRepository.create(todoList, {
53
- transaction: tx,
54
- });
55
- let err = {};
56
- // reading before commit in READ_COMMITED level should not find the entity
57
- const findBeforeCommit = await this.todoListRepository
58
- .findById(created.id)
59
- .catch(e => (err = e));
60
- await tx.commit();
61
- // throwing it after commit to avoid deadlocks
62
- if (err) {
63
- throw err;
64
- }
65
- return findBeforeCommit;
66
- }
67
- async ensureLocalTransactions() {
68
- // "Todo List" model is from Primary Datasource
69
- // and "AnyObject" model is from Secondary Datasource
70
- // this test case is to ensure transaction created on
71
- // one datasource can't be used in another
72
- const tx = await this.todoListRepository.beginTransaction({
73
- isolationLevel: types_1.Transaction.ISOLATION_LEVELS.SERIALIZABLE,
74
- });
75
- let err = null;
76
- try {
77
- await this.productRepository.create({
78
- name: 'phone',
79
- price: 5000,
80
- }, {
81
- transaction: tx,
82
- });
83
- }
84
- catch (e) {
85
- err = e;
86
- }
87
- await tx.commit();
88
- if (err) {
89
- throw new rest_1.HttpErrors[406](err.message);
90
- }
91
- // Won't reach till here if test passes
92
- throw new rest_1.HttpErrors[406]('Product created with non-local transaction.');
93
- }
94
- };
95
- exports.TransactionController = TransactionController;
96
- tslib_1.__decorate([
97
- (0, rest_1.post)('/transactions/todo-lists/commit'),
98
- tslib_1.__param(0, (0, rest_1.requestBody)({
99
- content: {
100
- 'application/json': {
101
- schema: (0, rest_1.getModelSchemaRef)(models_1.TodoList, {
102
- title: 'NewTodoList',
103
- exclude: ['id'],
104
- }),
105
- },
106
- },
107
- })),
108
- tslib_1.__metadata("design:type", Function),
109
- tslib_1.__metadata("design:paramtypes", [Object]),
110
- tslib_1.__metadata("design:returntype", Promise)
111
- ], TransactionController.prototype, "ensureTransactionCommit", null);
112
- tslib_1.__decorate([
113
- (0, rest_1.post)('/transactions/todo-lists/rollback'),
114
- tslib_1.__param(0, (0, rest_1.requestBody)({
115
- content: {
116
- 'application/json': {
117
- schema: (0, rest_1.getModelSchemaRef)(models_1.TodoList, {
118
- title: 'NewTodoList',
119
- exclude: ['id'],
120
- }),
121
- },
122
- },
123
- })),
124
- tslib_1.__metadata("design:type", Function),
125
- tslib_1.__metadata("design:paramtypes", [Object]),
126
- tslib_1.__metadata("design:returntype", Promise)
127
- ], TransactionController.prototype, "ensureRollback", null);
128
- tslib_1.__decorate([
129
- (0, rest_1.post)('/transactions/todo-lists/isolation/read_commited'),
130
- tslib_1.__param(0, (0, rest_1.requestBody)({
131
- content: {
132
- 'application/json': {
133
- schema: (0, rest_1.getModelSchemaRef)(models_1.TodoList, {
134
- title: 'NewTodoList',
135
- exclude: ['id'],
136
- }),
137
- },
138
- },
139
- })),
140
- tslib_1.__metadata("design:type", Function),
141
- tslib_1.__metadata("design:paramtypes", [Object]),
142
- tslib_1.__metadata("design:returntype", Promise)
143
- ], TransactionController.prototype, "ensureIsolatedTransaction", null);
144
- tslib_1.__decorate([
145
- (0, rest_1.get)('/transactions/ensure-local'),
146
- tslib_1.__metadata("design:type", Function),
147
- tslib_1.__metadata("design:paramtypes", []),
148
- tslib_1.__metadata("design:returntype", Promise)
149
- ], TransactionController.prototype, "ensureLocalTransactions", null);
150
- exports.TransactionController = TransactionController = tslib_1.__decorate([
151
- tslib_1.__param(0, (0, repository_1.repository)(repositories_1.TodoListRepository)),
152
- tslib_1.__param(1, (0, repository_1.repository)(repositories_1.ProductRepository)),
153
- tslib_1.__metadata("design:paramtypes", [repositories_1.TodoListRepository,
154
- repositories_1.ProductRepository])
155
- ], TransactionController);
156
- //# sourceMappingURL=transaction.controller.js.map
157
- //# sourceMappingURL=/Users/dianalau/code/loopback/loopback-next/extensions/sequelize/dist/__tests__/fixtures/controllers/transaction.controller.js.map
@@ -1,113 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserTodoListController = void 0;
4
- const tslib_1 = require("tslib");
5
- const repository_1 = require("@loopback/repository");
6
- const rest_1 = require("@loopback/rest");
7
- const models_1 = require("../models");
8
- const repositories_1 = require("../repositories");
9
- let UserTodoListController = class UserTodoListController {
10
- constructor(userRepository) {
11
- this.userRepository = userRepository;
12
- }
13
- async get(id, filter) {
14
- return this.userRepository.todoList(id).get(filter);
15
- }
16
- async create(id, todoList) {
17
- return this.userRepository.todoList(id).create(todoList);
18
- }
19
- async patch(id, todoList, where) {
20
- return this.userRepository.todoList(id).patch(todoList, where);
21
- }
22
- async delete(id, where) {
23
- return this.userRepository.todoList(id).delete(where);
24
- }
25
- };
26
- exports.UserTodoListController = UserTodoListController;
27
- tslib_1.__decorate([
28
- (0, rest_1.get)('/users/{id}/todo-list', {
29
- responses: {
30
- '200': {
31
- description: 'User has one TodoList',
32
- content: {
33
- 'application/json': {
34
- schema: (0, rest_1.getModelSchemaRef)(models_1.TodoList),
35
- },
36
- },
37
- },
38
- },
39
- }),
40
- tslib_1.__param(0, rest_1.param.path.number('id')),
41
- tslib_1.__param(1, rest_1.param.query.object('filter')),
42
- tslib_1.__metadata("design:type", Function),
43
- tslib_1.__metadata("design:paramtypes", [Number, Object]),
44
- tslib_1.__metadata("design:returntype", Promise)
45
- ], UserTodoListController.prototype, "get", null);
46
- tslib_1.__decorate([
47
- (0, rest_1.post)('/users/{id}/todo-list', {
48
- responses: {
49
- '200': {
50
- description: 'User model instance',
51
- content: { 'application/json': { schema: (0, rest_1.getModelSchemaRef)(models_1.TodoList) } },
52
- },
53
- },
54
- }),
55
- tslib_1.__param(0, rest_1.param.path.number('id')),
56
- tslib_1.__param(1, (0, rest_1.requestBody)({
57
- content: {
58
- 'application/json': {
59
- schema: (0, rest_1.getModelSchemaRef)(models_1.TodoList, {
60
- title: 'NewTodoListInUser',
61
- exclude: ['id'],
62
- optional: ['user'],
63
- }),
64
- },
65
- },
66
- })),
67
- tslib_1.__metadata("design:type", Function),
68
- tslib_1.__metadata("design:paramtypes", [Object, Object]),
69
- tslib_1.__metadata("design:returntype", Promise)
70
- ], UserTodoListController.prototype, "create", null);
71
- tslib_1.__decorate([
72
- (0, rest_1.patch)('/users/{id}/todo-list', {
73
- responses: {
74
- '200': {
75
- description: 'User.TodoList PATCH success count',
76
- content: { 'application/json': { schema: repository_1.CountSchema } },
77
- },
78
- },
79
- }),
80
- tslib_1.__param(0, rest_1.param.path.number('id')),
81
- tslib_1.__param(1, (0, rest_1.requestBody)({
82
- content: {
83
- 'application/json': {
84
- schema: (0, rest_1.getModelSchemaRef)(models_1.TodoList, { partial: true }),
85
- },
86
- },
87
- })),
88
- tslib_1.__param(2, rest_1.param.query.object('where', (0, rest_1.getWhereSchemaFor)(models_1.TodoList))),
89
- tslib_1.__metadata("design:type", Function),
90
- tslib_1.__metadata("design:paramtypes", [Number, Object, Object]),
91
- tslib_1.__metadata("design:returntype", Promise)
92
- ], UserTodoListController.prototype, "patch", null);
93
- tslib_1.__decorate([
94
- (0, rest_1.del)('/users/{id}/todo-list', {
95
- responses: {
96
- '200': {
97
- description: 'User.TodoList DELETE success count',
98
- content: { 'application/json': { schema: repository_1.CountSchema } },
99
- },
100
- },
101
- }),
102
- tslib_1.__param(0, rest_1.param.path.number('id')),
103
- tslib_1.__param(1, rest_1.param.query.object('where', (0, rest_1.getWhereSchemaFor)(models_1.TodoList))),
104
- tslib_1.__metadata("design:type", Function),
105
- tslib_1.__metadata("design:paramtypes", [Number, Object]),
106
- tslib_1.__metadata("design:returntype", Promise)
107
- ], UserTodoListController.prototype, "delete", null);
108
- exports.UserTodoListController = UserTodoListController = tslib_1.__decorate([
109
- tslib_1.__param(0, (0, repository_1.repository)(repositories_1.UserRepository)),
110
- tslib_1.__metadata("design:paramtypes", [repositories_1.UserRepository])
111
- ], UserTodoListController);
112
- //# sourceMappingURL=user-todo-list.controller.js.map
113
- //# sourceMappingURL=/Users/dianalau/code/loopback/loopback-next/extensions/sequelize/dist/__tests__/fixtures/controllers/user-todo-list.controller.js.map