@loopback/sequelize 0.1.0
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.
- package/LICENSE +25 -0
- package/README.md +194 -0
- package/dist/.sandbox/6646miobBk/application.js +15 -0
- package/dist/.sandbox/6646miobBk/controllers/book-category.controller.js +41 -0
- package/dist/.sandbox/6646miobBk/controllers/book.controller.js +210 -0
- package/dist/.sandbox/6646miobBk/controllers/category.controller.js +198 -0
- package/dist/.sandbox/6646miobBk/controllers/developer.controller.js +177 -0
- package/dist/.sandbox/6646miobBk/controllers/doctor-patient.controller.js +112 -0
- package/dist/.sandbox/6646miobBk/controllers/doctor.controller.js +177 -0
- package/dist/.sandbox/6646miobBk/controllers/index.js +20 -0
- package/dist/.sandbox/6646miobBk/controllers/patient.controller.js +165 -0
- package/dist/.sandbox/6646miobBk/controllers/programming-languange.controller.js +204 -0
- package/dist/.sandbox/6646miobBk/controllers/test.controller.base.js +25 -0
- package/dist/.sandbox/6646miobBk/controllers/todo-list-todo.controller.js +113 -0
- package/dist/.sandbox/6646miobBk/controllers/todo-list.controller.js +177 -0
- package/dist/.sandbox/6646miobBk/controllers/todo-todo-list.controller.js +41 -0
- package/dist/.sandbox/6646miobBk/controllers/todo.controller.js +177 -0
- package/dist/.sandbox/6646miobBk/controllers/user-todo-list.controller.js +113 -0
- package/dist/.sandbox/6646miobBk/controllers/user.controller.js +210 -0
- package/dist/.sandbox/6646miobBk/datasources/db.datasource.js +28 -0
- package/dist/.sandbox/6646miobBk/models/appointment.model.js +37 -0
- package/dist/.sandbox/6646miobBk/models/book.model.js +48 -0
- package/dist/.sandbox/6646miobBk/models/category.model.js +32 -0
- package/dist/.sandbox/6646miobBk/models/developer.model.js +40 -0
- package/dist/.sandbox/6646miobBk/models/doctor.model.js +44 -0
- package/dist/.sandbox/6646miobBk/models/index.js +15 -0
- package/dist/.sandbox/6646miobBk/models/patient.model.js +32 -0
- package/dist/.sandbox/6646miobBk/models/programming-language.model.js +32 -0
- package/dist/.sandbox/6646miobBk/models/todo-list.model.js +45 -0
- package/dist/.sandbox/6646miobBk/models/todo.model.js +44 -0
- package/dist/.sandbox/6646miobBk/models/user.model.js +85 -0
- package/dist/.sandbox/6646miobBk/repositories/appointment.repository.js +20 -0
- package/dist/.sandbox/6646miobBk/repositories/book.repository.js +25 -0
- package/dist/.sandbox/6646miobBk/repositories/category.repository.js +20 -0
- package/dist/.sandbox/6646miobBk/repositories/developer.repository.js +25 -0
- package/dist/.sandbox/6646miobBk/repositories/doctor.repository.js +27 -0
- package/dist/.sandbox/6646miobBk/repositories/index.js +15 -0
- package/dist/.sandbox/6646miobBk/repositories/patient.repository.js +20 -0
- package/dist/.sandbox/6646miobBk/repositories/programming-language.repository.js +20 -0
- package/dist/.sandbox/6646miobBk/repositories/todo-list.repository.js +25 -0
- package/dist/.sandbox/6646miobBk/repositories/todo.repository.js +25 -0
- package/dist/.sandbox/6646miobBk/repositories/user.repository.js +29 -0
- package/dist/component.d.ts +7 -0
- package/dist/component.js +30 -0
- package/dist/component.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/keys.d.ts +8 -0
- package/dist/keys.js +16 -0
- package/dist/keys.js.map +1 -0
- package/dist/sequelize/connector-mapping.d.ts +9 -0
- package/dist/sequelize/connector-mapping.js +19 -0
- package/dist/sequelize/connector-mapping.js.map +1 -0
- package/dist/sequelize/index.d.ts +2 -0
- package/dist/sequelize/index.js +10 -0
- package/dist/sequelize/index.js.map +1 -0
- package/dist/sequelize/operator-translation.d.ts +8 -0
- package/dist/sequelize/operator-translation.js +31 -0
- package/dist/sequelize/operator-translation.js.map +1 -0
- package/dist/sequelize/sequelize.datasource.base.d.ts +23 -0
- package/dist/sequelize/sequelize.datasource.base.js +60 -0
- package/dist/sequelize/sequelize.datasource.base.js.map +1 -0
- package/dist/sequelize/sequelize.model.d.ts +7 -0
- package/dist/sequelize/sequelize.model.js +24 -0
- package/dist/sequelize/sequelize.model.js.map +1 -0
- package/dist/sequelize/sequelize.repository.base.d.ts +231 -0
- package/dist/sequelize/sequelize.repository.base.js +835 -0
- package/dist/sequelize/sequelize.repository.base.js.map +1 -0
- package/dist/sequelize/utils.d.ts +6 -0
- package/dist/sequelize/utils.js +17 -0
- package/dist/sequelize/utils.js.map +1 -0
- package/dist/types.d.ts +9 -0
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -0
- package/package.json +64 -0
- package/src/component.ts +34 -0
- package/src/index.ts +9 -0
- package/src/keys.ts +16 -0
- package/src/sequelize/connector-mapping.ts +26 -0
- package/src/sequelize/index.ts +7 -0
- package/src/sequelize/operator-translation.ts +32 -0
- package/src/sequelize/sequelize.datasource.base.ts +81 -0
- package/src/sequelize/sequelize.model.ts +22 -0
- package/src/sequelize/sequelize.repository.base.ts +1246 -0
- package/src/sequelize/utils.ts +13 -0
- package/src/types.ts +19 -0
|
@@ -0,0 +1,177 @@
|
|
|
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
|
+
tslib_1.__decorate([
|
|
44
|
+
(0, rest_1.post)('/todos'),
|
|
45
|
+
(0, rest_1.response)(200, {
|
|
46
|
+
description: 'Todo model instance',
|
|
47
|
+
content: { 'application/json': { schema: (0, rest_1.getModelSchemaRef)(models_1.Todo) } },
|
|
48
|
+
}),
|
|
49
|
+
tslib_1.__param(0, (0, rest_1.requestBody)({
|
|
50
|
+
content: {
|
|
51
|
+
'application/json': {
|
|
52
|
+
schema: (0, rest_1.getModelSchemaRef)(models_1.Todo, {
|
|
53
|
+
title: 'NewTodo',
|
|
54
|
+
exclude: ['id'],
|
|
55
|
+
}),
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
})),
|
|
59
|
+
tslib_1.__metadata("design:type", Function),
|
|
60
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
61
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
62
|
+
], TodoController.prototype, "create", null);
|
|
63
|
+
tslib_1.__decorate([
|
|
64
|
+
(0, rest_1.get)('/todos/count'),
|
|
65
|
+
(0, rest_1.response)(200, {
|
|
66
|
+
description: 'Todo model count',
|
|
67
|
+
content: { 'application/json': { schema: repository_1.CountSchema } },
|
|
68
|
+
}),
|
|
69
|
+
tslib_1.__param(0, rest_1.param.where(models_1.Todo)),
|
|
70
|
+
tslib_1.__metadata("design:type", Function),
|
|
71
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
72
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
73
|
+
], TodoController.prototype, "count", null);
|
|
74
|
+
tslib_1.__decorate([
|
|
75
|
+
(0, rest_1.get)('/todos'),
|
|
76
|
+
(0, rest_1.response)(200, {
|
|
77
|
+
description: 'Array of Todo model instances',
|
|
78
|
+
content: {
|
|
79
|
+
'application/json': {
|
|
80
|
+
schema: {
|
|
81
|
+
type: 'array',
|
|
82
|
+
items: (0, rest_1.getModelSchemaRef)(models_1.Todo, { includeRelations: true }),
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
}),
|
|
87
|
+
tslib_1.__param(0, rest_1.param.filter(models_1.Todo)),
|
|
88
|
+
tslib_1.__metadata("design:type", Function),
|
|
89
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
90
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
91
|
+
], TodoController.prototype, "find", null);
|
|
92
|
+
tslib_1.__decorate([
|
|
93
|
+
(0, rest_1.patch)('/todos'),
|
|
94
|
+
(0, rest_1.response)(200, {
|
|
95
|
+
description: 'Todo PATCH success count',
|
|
96
|
+
content: { 'application/json': { schema: repository_1.CountSchema } },
|
|
97
|
+
}),
|
|
98
|
+
tslib_1.__param(0, (0, rest_1.requestBody)({
|
|
99
|
+
content: {
|
|
100
|
+
'application/json': {
|
|
101
|
+
schema: (0, rest_1.getModelSchemaRef)(models_1.Todo, { partial: true }),
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
})),
|
|
105
|
+
tslib_1.__param(1, rest_1.param.where(models_1.Todo)),
|
|
106
|
+
tslib_1.__metadata("design:type", Function),
|
|
107
|
+
tslib_1.__metadata("design:paramtypes", [models_1.Todo, Object]),
|
|
108
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
109
|
+
], TodoController.prototype, "updateAll", null);
|
|
110
|
+
tslib_1.__decorate([
|
|
111
|
+
(0, rest_1.get)('/todos/{id}'),
|
|
112
|
+
(0, rest_1.response)(200, {
|
|
113
|
+
description: 'Todo model instance',
|
|
114
|
+
content: {
|
|
115
|
+
'application/json': {
|
|
116
|
+
schema: (0, rest_1.getModelSchemaRef)(models_1.Todo, { includeRelations: true }),
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
}),
|
|
120
|
+
tslib_1.__param(0, rest_1.param.path.number('id')),
|
|
121
|
+
tslib_1.__param(1, rest_1.param.filter(models_1.Todo, { exclude: 'where' })),
|
|
122
|
+
tslib_1.__metadata("design:type", Function),
|
|
123
|
+
tslib_1.__metadata("design:paramtypes", [Number, Object]),
|
|
124
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
125
|
+
], TodoController.prototype, "findById", null);
|
|
126
|
+
tslib_1.__decorate([
|
|
127
|
+
(0, rest_1.patch)('/todos/{id}'),
|
|
128
|
+
(0, rest_1.response)(204, {
|
|
129
|
+
description: 'Todo PATCH success',
|
|
130
|
+
}),
|
|
131
|
+
tslib_1.__param(0, rest_1.param.path.number('id')),
|
|
132
|
+
tslib_1.__param(1, (0, rest_1.requestBody)({
|
|
133
|
+
content: {
|
|
134
|
+
'application/json': {
|
|
135
|
+
schema: (0, rest_1.getModelSchemaRef)(models_1.Todo, { partial: true }),
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
})),
|
|
139
|
+
tslib_1.__metadata("design:type", Function),
|
|
140
|
+
tslib_1.__metadata("design:paramtypes", [Number, models_1.Todo]),
|
|
141
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
142
|
+
], TodoController.prototype, "updateById", null);
|
|
143
|
+
tslib_1.__decorate([
|
|
144
|
+
(0, rest_1.put)('/todos/{id}'),
|
|
145
|
+
(0, rest_1.response)(204, {
|
|
146
|
+
description: 'Todo PUT success',
|
|
147
|
+
}),
|
|
148
|
+
tslib_1.__param(0, rest_1.param.path.number('id')),
|
|
149
|
+
tslib_1.__param(1, (0, rest_1.requestBody)()),
|
|
150
|
+
tslib_1.__metadata("design:type", Function),
|
|
151
|
+
tslib_1.__metadata("design:paramtypes", [Number, models_1.Todo]),
|
|
152
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
153
|
+
], TodoController.prototype, "replaceById", null);
|
|
154
|
+
tslib_1.__decorate([
|
|
155
|
+
(0, rest_1.del)('/todos/{id}'),
|
|
156
|
+
(0, rest_1.response)(204, {
|
|
157
|
+
description: 'Todo DELETE success',
|
|
158
|
+
}),
|
|
159
|
+
tslib_1.__param(0, rest_1.param.path.number('id')),
|
|
160
|
+
tslib_1.__metadata("design:type", Function),
|
|
161
|
+
tslib_1.__metadata("design:paramtypes", [Number]),
|
|
162
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
163
|
+
], TodoController.prototype, "deleteById", null);
|
|
164
|
+
tslib_1.__decorate([
|
|
165
|
+
(0, rest_1.get)('/todos/sync-sequelize-model'),
|
|
166
|
+
(0, rest_1.response)(200),
|
|
167
|
+
tslib_1.__metadata("design:type", Function),
|
|
168
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
169
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
170
|
+
], TodoController.prototype, "syncSequelizeModel", null);
|
|
171
|
+
TodoController = tslib_1.__decorate([
|
|
172
|
+
tslib_1.__param(0, (0, repository_1.repository)(repositories_1.TodoRepository)),
|
|
173
|
+
tslib_1.__metadata("design:paramtypes", [repositories_1.TodoRepository])
|
|
174
|
+
], TodoController);
|
|
175
|
+
exports.TodoController = 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
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
tslib_1.__decorate([
|
|
27
|
+
(0, rest_1.get)('/users/{id}/todo-list', {
|
|
28
|
+
responses: {
|
|
29
|
+
'200': {
|
|
30
|
+
description: 'User has one TodoList',
|
|
31
|
+
content: {
|
|
32
|
+
'application/json': {
|
|
33
|
+
schema: (0, rest_1.getModelSchemaRef)(models_1.TodoList),
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
tslib_1.__param(0, rest_1.param.path.number('id')),
|
|
40
|
+
tslib_1.__param(1, rest_1.param.query.object('filter')),
|
|
41
|
+
tslib_1.__metadata("design:type", Function),
|
|
42
|
+
tslib_1.__metadata("design:paramtypes", [Number, Object]),
|
|
43
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
44
|
+
], UserTodoListController.prototype, "get", null);
|
|
45
|
+
tslib_1.__decorate([
|
|
46
|
+
(0, rest_1.post)('/users/{id}/todo-list', {
|
|
47
|
+
responses: {
|
|
48
|
+
'200': {
|
|
49
|
+
description: 'User model instance',
|
|
50
|
+
content: { 'application/json': { schema: (0, rest_1.getModelSchemaRef)(models_1.TodoList) } },
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
tslib_1.__param(0, rest_1.param.path.number('id')),
|
|
55
|
+
tslib_1.__param(1, (0, rest_1.requestBody)({
|
|
56
|
+
content: {
|
|
57
|
+
'application/json': {
|
|
58
|
+
schema: (0, rest_1.getModelSchemaRef)(models_1.TodoList, {
|
|
59
|
+
title: 'NewTodoListInUser',
|
|
60
|
+
exclude: ['id'],
|
|
61
|
+
optional: ['user'],
|
|
62
|
+
}),
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
})),
|
|
66
|
+
tslib_1.__metadata("design:type", Function),
|
|
67
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
68
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
69
|
+
], UserTodoListController.prototype, "create", null);
|
|
70
|
+
tslib_1.__decorate([
|
|
71
|
+
(0, rest_1.patch)('/users/{id}/todo-list', {
|
|
72
|
+
responses: {
|
|
73
|
+
'200': {
|
|
74
|
+
description: 'User.TodoList PATCH success count',
|
|
75
|
+
content: { 'application/json': { schema: repository_1.CountSchema } },
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
}),
|
|
79
|
+
tslib_1.__param(0, rest_1.param.path.number('id')),
|
|
80
|
+
tslib_1.__param(1, (0, rest_1.requestBody)({
|
|
81
|
+
content: {
|
|
82
|
+
'application/json': {
|
|
83
|
+
schema: (0, rest_1.getModelSchemaRef)(models_1.TodoList, { partial: true }),
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
})),
|
|
87
|
+
tslib_1.__param(2, rest_1.param.query.object('where', (0, rest_1.getWhereSchemaFor)(models_1.TodoList))),
|
|
88
|
+
tslib_1.__metadata("design:type", Function),
|
|
89
|
+
tslib_1.__metadata("design:paramtypes", [Number, Object, Object]),
|
|
90
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
91
|
+
], UserTodoListController.prototype, "patch", null);
|
|
92
|
+
tslib_1.__decorate([
|
|
93
|
+
(0, rest_1.del)('/users/{id}/todo-list', {
|
|
94
|
+
responses: {
|
|
95
|
+
'200': {
|
|
96
|
+
description: 'User.TodoList DELETE success count',
|
|
97
|
+
content: { 'application/json': { schema: repository_1.CountSchema } },
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
}),
|
|
101
|
+
tslib_1.__param(0, rest_1.param.path.number('id')),
|
|
102
|
+
tslib_1.__param(1, rest_1.param.query.object('where', (0, rest_1.getWhereSchemaFor)(models_1.TodoList))),
|
|
103
|
+
tslib_1.__metadata("design:type", Function),
|
|
104
|
+
tslib_1.__metadata("design:paramtypes", [Number, Object]),
|
|
105
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
106
|
+
], UserTodoListController.prototype, "delete", null);
|
|
107
|
+
UserTodoListController = tslib_1.__decorate([
|
|
108
|
+
tslib_1.__param(0, (0, repository_1.repository)(repositories_1.UserRepository)),
|
|
109
|
+
tslib_1.__metadata("design:paramtypes", [repositories_1.UserRepository])
|
|
110
|
+
], UserTodoListController);
|
|
111
|
+
exports.UserTodoListController = 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
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserController = 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 UserController = class UserController extends test_controller_base_1.TestControllerBase {
|
|
11
|
+
constructor(userRepository) {
|
|
12
|
+
super(userRepository);
|
|
13
|
+
this.userRepository = userRepository;
|
|
14
|
+
}
|
|
15
|
+
async create(user) {
|
|
16
|
+
return this.userRepository.create(user);
|
|
17
|
+
}
|
|
18
|
+
async createAll(users) {
|
|
19
|
+
return this.userRepository.createAll(users);
|
|
20
|
+
}
|
|
21
|
+
async count(where) {
|
|
22
|
+
return this.userRepository.count(where);
|
|
23
|
+
}
|
|
24
|
+
async find(filter) {
|
|
25
|
+
return this.userRepository.find(filter);
|
|
26
|
+
}
|
|
27
|
+
async updateAll(user, where) {
|
|
28
|
+
return this.userRepository.updateAll(user, where);
|
|
29
|
+
}
|
|
30
|
+
async findById(id, filter) {
|
|
31
|
+
return this.userRepository.findById(id, filter);
|
|
32
|
+
}
|
|
33
|
+
async updateById(id, user) {
|
|
34
|
+
await this.userRepository.updateById(id, user);
|
|
35
|
+
}
|
|
36
|
+
async replaceById(id, user) {
|
|
37
|
+
await this.userRepository.replaceById(id, user);
|
|
38
|
+
}
|
|
39
|
+
async deleteById(id) {
|
|
40
|
+
await this.userRepository.deleteById(id);
|
|
41
|
+
}
|
|
42
|
+
async syncSequelizeModel() {
|
|
43
|
+
await this.beforeEach();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
tslib_1.__decorate([
|
|
47
|
+
(0, rest_1.post)('/users'),
|
|
48
|
+
(0, rest_1.response)(200, {
|
|
49
|
+
description: 'User model instance',
|
|
50
|
+
content: { 'application/json': { schema: (0, rest_1.getModelSchemaRef)(models_1.User) } },
|
|
51
|
+
}),
|
|
52
|
+
tslib_1.__param(0, (0, rest_1.requestBody)({
|
|
53
|
+
content: {
|
|
54
|
+
'application/json': {
|
|
55
|
+
schema: (0, rest_1.getModelSchemaRef)(models_1.User, {
|
|
56
|
+
title: 'NewUser',
|
|
57
|
+
exclude: ['id'],
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
})),
|
|
62
|
+
tslib_1.__metadata("design:type", Function),
|
|
63
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
64
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
65
|
+
], UserController.prototype, "create", null);
|
|
66
|
+
tslib_1.__decorate([
|
|
67
|
+
(0, rest_1.post)('/users-bulk'),
|
|
68
|
+
(0, rest_1.response)(200, {
|
|
69
|
+
description: 'User model instances',
|
|
70
|
+
content: {
|
|
71
|
+
'application/json': {
|
|
72
|
+
schema: {
|
|
73
|
+
type: 'array',
|
|
74
|
+
items: (0, rest_1.getModelSchemaRef)(models_1.User),
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
}),
|
|
79
|
+
tslib_1.__param(0, (0, rest_1.requestBody)({
|
|
80
|
+
content: {
|
|
81
|
+
'application/json': {
|
|
82
|
+
schema: {
|
|
83
|
+
type: 'array',
|
|
84
|
+
items: (0, rest_1.getModelSchemaRef)(models_1.User, {
|
|
85
|
+
title: 'NewUser',
|
|
86
|
+
exclude: ['id'],
|
|
87
|
+
}),
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
})),
|
|
92
|
+
tslib_1.__metadata("design:type", Function),
|
|
93
|
+
tslib_1.__metadata("design:paramtypes", [Array]),
|
|
94
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
95
|
+
], UserController.prototype, "createAll", null);
|
|
96
|
+
tslib_1.__decorate([
|
|
97
|
+
(0, rest_1.get)('/users/count'),
|
|
98
|
+
(0, rest_1.response)(200, {
|
|
99
|
+
description: 'User model count',
|
|
100
|
+
content: { 'application/json': { schema: repository_1.CountSchema } },
|
|
101
|
+
}),
|
|
102
|
+
tslib_1.__param(0, rest_1.param.where(models_1.User)),
|
|
103
|
+
tslib_1.__metadata("design:type", Function),
|
|
104
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
105
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
106
|
+
], UserController.prototype, "count", null);
|
|
107
|
+
tslib_1.__decorate([
|
|
108
|
+
(0, rest_1.get)('/users'),
|
|
109
|
+
(0, rest_1.response)(200, {
|
|
110
|
+
description: 'Array of User model instances',
|
|
111
|
+
content: {
|
|
112
|
+
'application/json': {
|
|
113
|
+
schema: {
|
|
114
|
+
type: 'array',
|
|
115
|
+
items: (0, rest_1.getModelSchemaRef)(models_1.User, { includeRelations: true }),
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
}),
|
|
120
|
+
tslib_1.__param(0, rest_1.param.filter(models_1.User)),
|
|
121
|
+
tslib_1.__metadata("design:type", Function),
|
|
122
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
123
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
124
|
+
], UserController.prototype, "find", null);
|
|
125
|
+
tslib_1.__decorate([
|
|
126
|
+
(0, rest_1.patch)('/users'),
|
|
127
|
+
(0, rest_1.response)(200, {
|
|
128
|
+
description: 'User PATCH success count',
|
|
129
|
+
content: { 'application/json': { schema: repository_1.CountSchema } },
|
|
130
|
+
}),
|
|
131
|
+
tslib_1.__param(0, (0, rest_1.requestBody)({
|
|
132
|
+
content: {
|
|
133
|
+
'application/json': {
|
|
134
|
+
schema: (0, rest_1.getModelSchemaRef)(models_1.User, { partial: true }),
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
})),
|
|
138
|
+
tslib_1.__param(1, rest_1.param.where(models_1.User)),
|
|
139
|
+
tslib_1.__metadata("design:type", Function),
|
|
140
|
+
tslib_1.__metadata("design:paramtypes", [models_1.User, Object]),
|
|
141
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
142
|
+
], UserController.prototype, "updateAll", null);
|
|
143
|
+
tslib_1.__decorate([
|
|
144
|
+
(0, rest_1.get)('/users/{id}'),
|
|
145
|
+
(0, rest_1.response)(200, {
|
|
146
|
+
description: 'User model instance',
|
|
147
|
+
content: {
|
|
148
|
+
'application/json': {
|
|
149
|
+
schema: (0, rest_1.getModelSchemaRef)(models_1.User, { includeRelations: true }),
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
}),
|
|
153
|
+
tslib_1.__param(0, rest_1.param.path.number('id')),
|
|
154
|
+
tslib_1.__param(1, rest_1.param.filter(models_1.User, { exclude: 'where' })),
|
|
155
|
+
tslib_1.__metadata("design:type", Function),
|
|
156
|
+
tslib_1.__metadata("design:paramtypes", [Number, Object]),
|
|
157
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
158
|
+
], UserController.prototype, "findById", null);
|
|
159
|
+
tslib_1.__decorate([
|
|
160
|
+
(0, rest_1.patch)('/users/{id}'),
|
|
161
|
+
(0, rest_1.response)(204, {
|
|
162
|
+
description: 'User PATCH success',
|
|
163
|
+
}),
|
|
164
|
+
tslib_1.__param(0, rest_1.param.path.number('id')),
|
|
165
|
+
tslib_1.__param(1, (0, rest_1.requestBody)({
|
|
166
|
+
content: {
|
|
167
|
+
'application/json': {
|
|
168
|
+
schema: (0, rest_1.getModelSchemaRef)(models_1.User, { partial: true }),
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
})),
|
|
172
|
+
tslib_1.__metadata("design:type", Function),
|
|
173
|
+
tslib_1.__metadata("design:paramtypes", [Number, models_1.User]),
|
|
174
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
175
|
+
], UserController.prototype, "updateById", null);
|
|
176
|
+
tslib_1.__decorate([
|
|
177
|
+
(0, rest_1.put)('/users/{id}'),
|
|
178
|
+
(0, rest_1.response)(204, {
|
|
179
|
+
description: 'User PUT success',
|
|
180
|
+
}),
|
|
181
|
+
tslib_1.__param(0, rest_1.param.path.number('id')),
|
|
182
|
+
tslib_1.__param(1, (0, rest_1.requestBody)()),
|
|
183
|
+
tslib_1.__metadata("design:type", Function),
|
|
184
|
+
tslib_1.__metadata("design:paramtypes", [Number, models_1.User]),
|
|
185
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
186
|
+
], UserController.prototype, "replaceById", null);
|
|
187
|
+
tslib_1.__decorate([
|
|
188
|
+
(0, rest_1.del)('/users/{id}'),
|
|
189
|
+
(0, rest_1.response)(204, {
|
|
190
|
+
description: 'User DELETE success',
|
|
191
|
+
}),
|
|
192
|
+
tslib_1.__param(0, rest_1.param.path.number('id')),
|
|
193
|
+
tslib_1.__metadata("design:type", Function),
|
|
194
|
+
tslib_1.__metadata("design:paramtypes", [Number]),
|
|
195
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
196
|
+
], UserController.prototype, "deleteById", null);
|
|
197
|
+
tslib_1.__decorate([
|
|
198
|
+
(0, rest_1.get)('/users/sync-sequelize-model'),
|
|
199
|
+
(0, rest_1.response)(200),
|
|
200
|
+
tslib_1.__metadata("design:type", Function),
|
|
201
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
202
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
203
|
+
], UserController.prototype, "syncSequelizeModel", null);
|
|
204
|
+
UserController = tslib_1.__decorate([
|
|
205
|
+
tslib_1.__param(0, (0, repository_1.repository)(repositories_1.UserRepository)),
|
|
206
|
+
tslib_1.__metadata("design:paramtypes", [repositories_1.UserRepository])
|
|
207
|
+
], UserController);
|
|
208
|
+
exports.UserController = UserController;
|
|
209
|
+
//# sourceMappingURL=user.controller.js.map
|
|
210
|
+
//# sourceMappingURL=/Users/dianalau/code/loopback/loopback-next/extensions/sequelize/dist/__tests__/fixtures/controllers/user.controller.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DbDataSource = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@loopback/core");
|
|
6
|
+
const sequelize_1 = require("../../../sequelize");
|
|
7
|
+
const config = {
|
|
8
|
+
name: 'db',
|
|
9
|
+
host: '0.0.0.0',
|
|
10
|
+
connector: 'sqlite3',
|
|
11
|
+
database: 'database',
|
|
12
|
+
file: ':memory:',
|
|
13
|
+
};
|
|
14
|
+
let DbDataSource = class DbDataSource extends sequelize_1.SequelizeDataSource {
|
|
15
|
+
constructor(dsConfig = config) {
|
|
16
|
+
super(dsConfig);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
DbDataSource.dataSourceName = 'db';
|
|
20
|
+
DbDataSource.defaultConfig = config;
|
|
21
|
+
DbDataSource = tslib_1.__decorate([
|
|
22
|
+
(0, core_1.lifeCycleObserver)('datasource'),
|
|
23
|
+
tslib_1.__param(0, (0, core_1.inject)('datasources.config.db', { optional: true })),
|
|
24
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
25
|
+
], DbDataSource);
|
|
26
|
+
exports.DbDataSource = DbDataSource;
|
|
27
|
+
//# sourceMappingURL=db.datasource.js.map
|
|
28
|
+
//# sourceMappingURL=/Users/dianalau/code/loopback/loopback-next/extensions/sequelize/dist/__tests__/fixtures/datasources/db.datasource.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Appointment = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const repository_1 = require("@loopback/repository");
|
|
6
|
+
let Appointment = class Appointment extends repository_1.Entity {
|
|
7
|
+
constructor(data) {
|
|
8
|
+
super(data);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
tslib_1.__decorate([
|
|
12
|
+
(0, repository_1.property)({
|
|
13
|
+
type: 'number',
|
|
14
|
+
id: true,
|
|
15
|
+
generated: true,
|
|
16
|
+
}),
|
|
17
|
+
tslib_1.__metadata("design:type", Number)
|
|
18
|
+
], Appointment.prototype, "id", void 0);
|
|
19
|
+
tslib_1.__decorate([
|
|
20
|
+
(0, repository_1.property)({
|
|
21
|
+
type: 'number',
|
|
22
|
+
}),
|
|
23
|
+
tslib_1.__metadata("design:type", Number)
|
|
24
|
+
], Appointment.prototype, "doctorId", void 0);
|
|
25
|
+
tslib_1.__decorate([
|
|
26
|
+
(0, repository_1.property)({
|
|
27
|
+
type: 'number',
|
|
28
|
+
}),
|
|
29
|
+
tslib_1.__metadata("design:type", Number)
|
|
30
|
+
], Appointment.prototype, "patientId", void 0);
|
|
31
|
+
Appointment = tslib_1.__decorate([
|
|
32
|
+
(0, repository_1.model)(),
|
|
33
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
34
|
+
], Appointment);
|
|
35
|
+
exports.Appointment = Appointment;
|
|
36
|
+
//# sourceMappingURL=appointment.model.js.map
|
|
37
|
+
//# sourceMappingURL=/Users/dianalau/code/loopback/loopback-next/extensions/sequelize/dist/__tests__/fixtures/models/appointment.model.js.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Book = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const repository_1 = require("@loopback/repository");
|
|
6
|
+
const category_model_1 = require("./category.model");
|
|
7
|
+
let Book = class Book extends repository_1.Entity {
|
|
8
|
+
constructor(data) {
|
|
9
|
+
super(data);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
tslib_1.__decorate([
|
|
13
|
+
(0, repository_1.property)({
|
|
14
|
+
type: 'number',
|
|
15
|
+
id: true,
|
|
16
|
+
generated: true,
|
|
17
|
+
}),
|
|
18
|
+
tslib_1.__metadata("design:type", Number)
|
|
19
|
+
], Book.prototype, "id", void 0);
|
|
20
|
+
tslib_1.__decorate([
|
|
21
|
+
(0, repository_1.property)({
|
|
22
|
+
type: 'string',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
tslib_1.__metadata("design:type", String)
|
|
26
|
+
], Book.prototype, "title", void 0);
|
|
27
|
+
tslib_1.__decorate([
|
|
28
|
+
(0, repository_1.property)({
|
|
29
|
+
type: 'number',
|
|
30
|
+
postgresql: {
|
|
31
|
+
dataType: 'float',
|
|
32
|
+
precision: 20,
|
|
33
|
+
scale: 4,
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
tslib_1.__metadata("design:type", Number)
|
|
37
|
+
], Book.prototype, "rating", void 0);
|
|
38
|
+
tslib_1.__decorate([
|
|
39
|
+
(0, repository_1.belongsTo)(() => category_model_1.Category),
|
|
40
|
+
tslib_1.__metadata("design:type", Number)
|
|
41
|
+
], Book.prototype, "categoryId", void 0);
|
|
42
|
+
Book = tslib_1.__decorate([
|
|
43
|
+
(0, repository_1.model)(),
|
|
44
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
45
|
+
], Book);
|
|
46
|
+
exports.Book = Book;
|
|
47
|
+
//# sourceMappingURL=book.model.js.map
|
|
48
|
+
//# sourceMappingURL=/Users/dianalau/code/loopback/loopback-next/extensions/sequelize/dist/__tests__/fixtures/models/book.model.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Category = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const repository_1 = require("@loopback/repository");
|
|
6
|
+
let Category = class Category extends repository_1.Entity {
|
|
7
|
+
constructor(data) {
|
|
8
|
+
super(data);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
tslib_1.__decorate([
|
|
12
|
+
(0, repository_1.property)({
|
|
13
|
+
type: 'number',
|
|
14
|
+
id: true,
|
|
15
|
+
generated: true,
|
|
16
|
+
}),
|
|
17
|
+
tslib_1.__metadata("design:type", Number)
|
|
18
|
+
], Category.prototype, "id", void 0);
|
|
19
|
+
tslib_1.__decorate([
|
|
20
|
+
(0, repository_1.property)({
|
|
21
|
+
type: 'string',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
tslib_1.__metadata("design:type", String)
|
|
25
|
+
], Category.prototype, "name", void 0);
|
|
26
|
+
Category = tslib_1.__decorate([
|
|
27
|
+
(0, repository_1.model)(),
|
|
28
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
29
|
+
], Category);
|
|
30
|
+
exports.Category = Category;
|
|
31
|
+
//# sourceMappingURL=category.model.js.map
|
|
32
|
+
//# sourceMappingURL=/Users/dianalau/code/loopback/loopback-next/extensions/sequelize/dist/__tests__/fixtures/models/category.model.js.map
|