@obisey/nest 0.1.36 → 0.1.38
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/package.json +1 -1
- package/prototipos/baseResolver.js +16 -8
- package/prototipos/utils/cachear.js +1 -0
- package/types.js +2 -2
package/package.json
CHANGED
|
@@ -68,7 +68,7 @@ function BaseResolver(modelo) {
|
|
|
68
68
|
// );
|
|
69
69
|
return servicio
|
|
70
70
|
.findByPk(IdModelo, pagina)
|
|
71
|
-
.then((item) => item.$get(planeta));
|
|
71
|
+
.then((item) => item ? item.$get(planeta) : null);
|
|
72
72
|
},
|
|
73
73
|
ligar: async (servicio, alias, objeto, peticion, borrarSSR = false) => {
|
|
74
74
|
return this.eliminarCache([
|
|
@@ -110,7 +110,7 @@ function BaseResolver(modelo) {
|
|
|
110
110
|
// imprimir(`${modelo} ${IdModelo} hasOne query ${planeta}`);
|
|
111
111
|
return servicio
|
|
112
112
|
.findByPk(IdModelo, pagina)
|
|
113
|
-
.then((item) => item.$get(planeta));
|
|
113
|
+
.then((item) => item ? item.$get(planeta) : null);
|
|
114
114
|
},
|
|
115
115
|
ligar: async (servicio, alias, IdModelo, IdPlaneta, through = null, borrarSSR = false) => this.ligar({
|
|
116
116
|
universo,
|
|
@@ -155,7 +155,7 @@ function BaseResolver(modelo) {
|
|
|
155
155
|
// );
|
|
156
156
|
return servicio
|
|
157
157
|
.findByPk(IdModelo, pagina)
|
|
158
|
-
.then((item) => item.$get(planeta));
|
|
158
|
+
.then((item) => item ? item.$get(planeta) : null);
|
|
159
159
|
},
|
|
160
160
|
ligar: async (servicio, alias, IdModelo, IdPlaneta, through = null, borrarSSR = false) => this.ligar({
|
|
161
161
|
universo,
|
|
@@ -198,7 +198,7 @@ function BaseResolver(modelo) {
|
|
|
198
198
|
// imprimir(`${modelo} ${IdModelo} nodo query ${planeta}`);
|
|
199
199
|
return servicio
|
|
200
200
|
.findByPk(IdModelo, pagina)
|
|
201
|
-
.then((item) => item.$get(planeta));
|
|
201
|
+
.then((item) => item ? item.$get(planeta) : null);
|
|
202
202
|
},
|
|
203
203
|
ligar: async (servicio, alias, IdModelo, IdPlaneta, through, borrarSSR = false) => this.ligar({
|
|
204
204
|
universo,
|
|
@@ -241,7 +241,7 @@ function BaseResolver(modelo) {
|
|
|
241
241
|
// imprimir(`${modelo} ${IdModelo} especial query ${planeta}`);
|
|
242
242
|
return servicio
|
|
243
243
|
.findByPk(IdModelo, pagina)
|
|
244
|
-
.then((item) => item.$get(planeta));
|
|
244
|
+
.then((item) => item ? item.$get(planeta) : null);
|
|
245
245
|
},
|
|
246
246
|
ligar: async (servicio, alias, IdModelo, IdPlaneta, through = null, borrarSSR) => this.ligar({
|
|
247
247
|
universo,
|
|
@@ -289,7 +289,7 @@ function BaseResolver(modelo) {
|
|
|
289
289
|
// );
|
|
290
290
|
return servicio
|
|
291
291
|
.findByPk(IdModelo, pagina)
|
|
292
|
-
.then((item) => item.$get(planeta));
|
|
292
|
+
.then((item) => item ? item.$get(planeta) : null);
|
|
293
293
|
},
|
|
294
294
|
subResolvefield: async (item, where, cacheable, Clase) => this.muchos({
|
|
295
295
|
universo,
|
|
@@ -308,7 +308,7 @@ function BaseResolver(modelo) {
|
|
|
308
308
|
// );
|
|
309
309
|
return servicio
|
|
310
310
|
.findByPk(IdModelo, pagina)
|
|
311
|
-
.then((item) => item.$get(planeta));
|
|
311
|
+
.then((item) => item ? item.$get(planeta) : null);
|
|
312
312
|
},
|
|
313
313
|
ligar: async (IdModelo, IdPlaneta, borrarSSR) => {
|
|
314
314
|
// imprimir(
|
|
@@ -542,6 +542,9 @@ function BaseResolver(modelo) {
|
|
|
542
542
|
], borrarSSR)
|
|
543
543
|
.then(() => servicio.findByPk(IdModelo))
|
|
544
544
|
.then((item) => {
|
|
545
|
+
if (tipo === 'hasOne') {
|
|
546
|
+
return item.$set(alias, IdPlaneta);
|
|
547
|
+
}
|
|
545
548
|
return item.$add(alias, IdPlaneta, through ? { through } : null);
|
|
546
549
|
})
|
|
547
550
|
.then((response) => true)
|
|
@@ -570,7 +573,12 @@ function BaseResolver(modelo) {
|
|
|
570
573
|
...crearKey(planeta, IdPlaneta),
|
|
571
574
|
], borrarSSR)
|
|
572
575
|
.then(() => servicio.findByPk(IdModelo))
|
|
573
|
-
.then((item) =>
|
|
576
|
+
.then((item) => {
|
|
577
|
+
if (tipo === 'belongsTo' || tipo === 'hasOne') {
|
|
578
|
+
return item.$set(alias, null);
|
|
579
|
+
}
|
|
580
|
+
return item.$remove(alias, IdPlaneta);
|
|
581
|
+
})
|
|
574
582
|
.then(() => true)
|
|
575
583
|
.catch((err) => {
|
|
576
584
|
// log(chalk.red('desligar', alias, err, '***********'));
|
package/types.js
CHANGED
|
@@ -12,8 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.UtilsTypes = exports.OrderInput = exports.ArgsFechas = exports.Status = exports.Conteo = exports.peticion = exports.paginate = void 0;
|
|
13
13
|
const graphql_1 = require("@nestjs/graphql");
|
|
14
14
|
const paginate = ({ where, pagina, limite, order }) => {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const limit = limite ?? 20;
|
|
16
|
+
const offset = ((pagina ?? 1) - 1) * limit;
|
|
17
17
|
return {
|
|
18
18
|
where,
|
|
19
19
|
offset,
|