remult 0.27.12 → 0.27.13
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/esm/server/get-remult-admin-html.js +1 -1
- package/esm/server/remult-admin.js +2 -0
- package/esm/server/remult-api-server.js +1 -1
- package/esm/src/data-providers/sql-database.js +2 -25
- package/esm/src/remult3/RepositoryImplementation.js +8 -1
- package/package.json +1 -1
- package/server/get-remult-admin-html.js +1 -1
- package/server/remult-admin.d.ts +4 -0
- package/server/remult-admin.js +12 -10
- package/server/remult-api-server.js +7 -7
- package/src/data-providers/sql-database.js +10 -69
- package/src/remult3/RepositoryImplementation.js +8 -1
|
@@ -70,6 +70,7 @@ export function buildEntityInfo(options) {
|
|
|
70
70
|
valFieldKey,
|
|
71
71
|
caption: x.caption,
|
|
72
72
|
relationToOne: relation,
|
|
73
|
+
inputType: x.inputType,
|
|
73
74
|
type: x.valueConverter.fieldTypeInDb == 'json'
|
|
74
75
|
? 'json'
|
|
75
76
|
: x.valueType === Number
|
|
@@ -88,6 +89,7 @@ export function buildEntityInfo(options) {
|
|
|
88
89
|
ids,
|
|
89
90
|
fields,
|
|
90
91
|
relations,
|
|
92
|
+
defaultOrderBy: metadata.options.defaultOrderBy ?? { id: 'asc' },
|
|
91
93
|
});
|
|
92
94
|
}
|
|
93
95
|
}
|
|
@@ -327,12 +327,12 @@ export class RemultServerImplementation {
|
|
|
327
327
|
},
|
|
328
328
|
});
|
|
329
329
|
}
|
|
330
|
+
await what(remult, myReq, myRes, genReq, origRes, req);
|
|
330
331
|
}
|
|
331
332
|
finally {
|
|
332
333
|
remultStatic.asyncContext.setInInitRequest(false);
|
|
333
334
|
}
|
|
334
335
|
}
|
|
335
|
-
await what(remult, myReq, myRes, genReq, origRes, req);
|
|
336
336
|
});
|
|
337
337
|
}
|
|
338
338
|
catch (err) {
|
|
@@ -502,29 +502,6 @@ class myDummySQLCommand {
|
|
|
502
502
|
return val.toString();
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
|
-
async function bulkInsert(array, db) {
|
|
506
|
-
if (array.length == 0)
|
|
507
|
-
return;
|
|
508
|
-
const chunkSize = 250;
|
|
509
|
-
for (let i = 0; i < array.length; i += chunkSize) {
|
|
510
|
-
const items = array.slice(i, i + chunkSize);
|
|
511
|
-
// do whatever
|
|
512
|
-
const c = db.createCommand();
|
|
513
|
-
let sql = 'insert into ' +
|
|
514
|
-
(await items[0]._.metadata.dbName) +
|
|
515
|
-
' (' +
|
|
516
|
-
(await Promise.all(items[0]._.metadata.fields.toArray().map((f) => f.dbName))).join(',') +
|
|
517
|
-
') values ';
|
|
518
|
-
sql += items
|
|
519
|
-
.map((row) => '(' +
|
|
520
|
-
row.$.toArray()
|
|
521
|
-
.map((f) => c.param(f.metadata.valueConverter.toDb(f.value)))
|
|
522
|
-
.join(', ') +
|
|
523
|
-
')')
|
|
524
|
-
.join(',');
|
|
525
|
-
await c.execute(sql);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
505
|
export function getRowAfterUpdate(meta, dataProvider, data, id, operation) {
|
|
529
506
|
const idFilter = id !== undefined ? meta.idMetadata.getIdFilter(id) : {};
|
|
530
507
|
return dataProvider
|
|
@@ -614,9 +591,9 @@ export async function groupByImpl(options, e, r, orderByNullFirst, limitSyntax)
|
|
|
614
591
|
orderBy += ' desc';
|
|
615
592
|
if (orderByNullFirst) {
|
|
616
593
|
if (x.isDescending)
|
|
617
|
-
|
|
594
|
+
orderBy += ' nulls last';
|
|
618
595
|
else
|
|
619
|
-
|
|
596
|
+
orderBy += ' nulls first';
|
|
620
597
|
}
|
|
621
598
|
}
|
|
622
599
|
if (orderBy)
|
|
@@ -713,7 +713,9 @@ export class RepositoryImplementation {
|
|
|
713
713
|
//I've used define property to hide this member from console.lo g
|
|
714
714
|
get: () => row,
|
|
715
715
|
});
|
|
716
|
+
row.id = row.getId();
|
|
716
717
|
row.saveOriginalData();
|
|
718
|
+
row.originalId = row.id;
|
|
717
719
|
return result;
|
|
718
720
|
}
|
|
719
721
|
}
|
|
@@ -1412,6 +1414,8 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1412
1414
|
updatedRow = (await this.edp.find({ where: await this.getIdFilter() }))[0];
|
|
1413
1415
|
}
|
|
1414
1416
|
else {
|
|
1417
|
+
if (this.id === undefined)
|
|
1418
|
+
throw new Error('Invalid operation, id is undefined');
|
|
1415
1419
|
updatedRow = await this.edp.update(this.id, changesOnly);
|
|
1416
1420
|
}
|
|
1417
1421
|
}
|
|
@@ -1488,8 +1492,11 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1488
1492
|
}
|
|
1489
1493
|
this.__assertValidity();
|
|
1490
1494
|
try {
|
|
1491
|
-
if (doDelete)
|
|
1495
|
+
if (doDelete) {
|
|
1496
|
+
if (this.id === undefined)
|
|
1497
|
+
throw new Error('Invalid operation, id is undefined');
|
|
1492
1498
|
await this.edp.delete(this.id);
|
|
1499
|
+
}
|
|
1493
1500
|
if (!this.repo._dataProvider.isProxy) {
|
|
1494
1501
|
if (this.info.entityInfo.deleted)
|
|
1495
1502
|
await this.info.entityInfo.deleted(this.instance, e);
|