@simitgroup/simpleapp-generator 2.0.1-o-alpha → 2.0.1-q-alpha
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/ReleaseNote.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
[2.0.1q-alpha]
|
|
2
|
+
|
|
3
|
+
1. fixagain delete record cant work in transactions, sharded env
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
[2.0.1p-alpha]
|
|
8
|
+
|
|
9
|
+
1. fix delete record cant work in transactions, sharded env
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
1
13
|
[2.0.1o-alpha]
|
|
2
14
|
|
|
3
15
|
1. fetch branch image url, and fix maintenance mode data
|
package/package.json
CHANGED
|
@@ -357,7 +357,6 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
-
|
|
361
360
|
/**
|
|
362
361
|
* create many from array, for performance reason it submit all item in 1 go, so it won't implement hooks
|
|
363
362
|
* @param appuser
|
|
@@ -377,7 +376,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
377
376
|
}
|
|
378
377
|
const dbsession = appuser.getDBSession();
|
|
379
378
|
if (dbsession && !dbsession.inTransaction()) {
|
|
380
|
-
dbsession.startTransaction({readConcern:{level:
|
|
379
|
+
dbsession.startTransaction({ readConcern: { level: 'snapshot' }, writeConcern: { w: 'majority' }, readPreference: 'primary' });
|
|
381
380
|
}
|
|
382
381
|
|
|
383
382
|
try {
|
|
@@ -404,7 +403,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
404
403
|
}
|
|
405
404
|
const dbsession = appuser.getDBSession();
|
|
406
405
|
if (dbsession && !dbsession.inTransaction() && !noStartTransaction) {
|
|
407
|
-
dbsession.startTransaction({readConcern:{level:
|
|
406
|
+
dbsession.startTransaction({ readConcern: { level: 'snapshot' }, writeConcern: { w: 'majority' }, readPreference: 'primary' });
|
|
408
407
|
}
|
|
409
408
|
|
|
410
409
|
this.logger.debug('this.withDocNumberFormat :' + this.withDocNumberFormat + ' && ' + '!data[this.documentIdentityCode] ==' + !data[this.documentIdentityCode]);
|
|
@@ -550,7 +549,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
550
549
|
}
|
|
551
550
|
const dbsession = appuser.getDBSession();
|
|
552
551
|
if (dbsession && !dbsession.inTransaction()) {
|
|
553
|
-
dbsession.startTransaction({readConcern:{level:
|
|
552
|
+
dbsession.startTransaction({ readConcern: { level: 'snapshot' }, writeConcern: { w: 'majority' }, readPreference: 'primary' });
|
|
554
553
|
}
|
|
555
554
|
|
|
556
555
|
let dependency;
|
|
@@ -561,7 +560,6 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
561
560
|
// if (this.hooks.beforeDelete) await this.hooks.beforeDelete(appuser, id, deletedata);
|
|
562
561
|
this.logger.debug('delete record', this.documentName, id);
|
|
563
562
|
dependency = await this.getRelatedRecords(appuser, id);
|
|
564
|
-
//console.log('dependency', dependency);
|
|
565
563
|
if (!dependency) {
|
|
566
564
|
const filterIsolation = this.getIsolationFilter(appuser);
|
|
567
565
|
this.polishIsolationFilter(filterIsolation);
|
|
@@ -629,7 +627,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
629
627
|
|
|
630
628
|
const dbsession = appuser.getDBSession();
|
|
631
629
|
if (dbsession && !dbsession.inTransaction() && !noStartTransaction) {
|
|
632
|
-
dbsession.startTransaction({readConcern:{level:
|
|
630
|
+
dbsession.startTransaction({ readConcern: { level: 'snapshot' }, writeConcern: { w: 'majority' }, readPreference: 'primary' });
|
|
633
631
|
}
|
|
634
632
|
// try {
|
|
635
633
|
Object.assign(data, appuser.getUpdateFilter());
|
|
@@ -688,7 +686,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
688
686
|
|
|
689
687
|
const dbsession = appuser.getDBSession();
|
|
690
688
|
if (dbsession && !dbsession.inTransaction()) {
|
|
691
|
-
dbsession.startTransaction({readConcern:{level:
|
|
689
|
+
dbsession.startTransaction({ readConcern: { level: 'snapshot' }, writeConcern: { w: 'majority' }, readPreference: 'primary' });
|
|
692
690
|
}
|
|
693
691
|
// try {
|
|
694
692
|
// Object.assign(data, appuser.getUpdateFilter());
|
|
@@ -744,7 +742,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
744
742
|
await this.runEvent(appuser, this.setHookName('beforePatch'), { id: id, patchData: data, prevData: existingdata }, false);
|
|
745
743
|
const dbsession = appuser.getDBSession();
|
|
746
744
|
if (dbsession && !dbsession.inTransaction()) {
|
|
747
|
-
dbsession.startTransaction({readConcern:{level:
|
|
745
|
+
dbsession.startTransaction({ readConcern: { level: 'snapshot' }, writeConcern: { w: 'majority' }, readPreference: 'primary' });
|
|
748
746
|
}
|
|
749
747
|
// try {
|
|
750
748
|
Object.assign(data, appuser.getUpdateFilter());
|
|
@@ -782,7 +780,21 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
782
780
|
throw new InternalServerErrorException(err.message);
|
|
783
781
|
}
|
|
784
782
|
};
|
|
785
|
-
|
|
783
|
+
async deleteMany(appUser: UserContext, filter: FilterQuery<T>) {
|
|
784
|
+
const dbsession = appUser.getDBSession();
|
|
785
|
+
if (dbsession && !dbsession.inTransaction()) {
|
|
786
|
+
dbsession.startTransaction({ readConcern: { level: 'snapshot' }, writeConcern: { w: 'majority' }, readPreference: 'primary' });
|
|
787
|
+
}
|
|
788
|
+
const searchResult = await this.search(appUser, filter, []);
|
|
789
|
+
const ids = searchResult.map((row) => row._id);
|
|
790
|
+
const result = await this.doc.deleteMany({ _id: { $in: ids } });
|
|
791
|
+
console.log(`Delete ${this.documentName} ids`, ids, result);
|
|
792
|
+
for (const id of ids) {
|
|
793
|
+
appUser.addDeletedRecordId(this.documentName, id);
|
|
794
|
+
}
|
|
795
|
+
return result;
|
|
796
|
+
//updateMany(isolationFilter, { $set: patch }, { session: dbsession });
|
|
797
|
+
}
|
|
786
798
|
async patchMany<T>(appuser: UserContext, data: PatchManyRequest<T>) {
|
|
787
799
|
// filter = {
|
|
788
800
|
// _id: '7eb2661a-6ea6-406e-b868-2e8b19c4658b',
|
|
@@ -799,7 +811,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
799
811
|
// Get DB Session
|
|
800
812
|
const dbsession = appuser.getDBSession();
|
|
801
813
|
if (dbsession && !dbsession.inTransaction()) {
|
|
802
|
-
dbsession.startTransaction({readConcern:{level:
|
|
814
|
+
dbsession.startTransaction({ readConcern: { level: 'snapshot' }, writeConcern: { w: 'majority' }, readPreference: 'primary' });
|
|
803
815
|
}
|
|
804
816
|
|
|
805
817
|
const result = await this.doc.updateMany(isolationFilter, { $set: patch }, { session: dbsession });
|
|
@@ -836,10 +848,14 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
836
848
|
//not deleted in current session, check from database
|
|
837
849
|
const filter = {};
|
|
838
850
|
filter[fkey] = id;
|
|
839
|
-
const result = await collection.findOne(filter, {
|
|
851
|
+
const result:any = await collection.findOne(filter, {
|
|
840
852
|
session: appuser.getDBSession(),
|
|
841
853
|
});
|
|
842
854
|
if (result) {
|
|
855
|
+
//record deleted but not yet commit, safely ignore
|
|
856
|
+
if(appuser.searchDeletedRecordId(collectionname, result._id))continue;
|
|
857
|
+
|
|
858
|
+
|
|
843
859
|
this.logger.error(result, `related result found in ${collectionname} ${fkey} = ${id}`);
|
|
844
860
|
return result;
|
|
845
861
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<button
|
|
7
7
|
type="button"
|
|
8
8
|
:readonly="readonly"
|
|
9
|
-
class="cursor-pointer text-primary-600"
|
|
9
|
+
class="cursor-pointer text-primary-600 line-clamp-1 text-left w-full"
|
|
10
10
|
tabindex="0"
|
|
11
11
|
@click="openViewer(true)"
|
|
12
12
|
>
|
|
@@ -22,15 +22,13 @@
|
|
|
22
22
|
:id="inputId"
|
|
23
23
|
ref="autocompleteinput"
|
|
24
24
|
type="button"
|
|
25
|
-
class="cursor-pointer text-primary-600 flex-1 text-left"
|
|
25
|
+
class="cursor-pointer text-primary-600 flex-1 text-left line-clamp-1"
|
|
26
26
|
@click="openViewer(false)"
|
|
27
27
|
>
|
|
28
28
|
{{ modelValue && modelValue.label ? modelValue.label : "-" }}
|
|
29
29
|
</button>
|
|
30
30
|
|
|
31
|
-
<div
|
|
32
|
-
class="text-right text-white align-middle"
|
|
33
|
-
>
|
|
31
|
+
<div class="text-right text-white align-middle">
|
|
34
32
|
<button
|
|
35
33
|
type="button"
|
|
36
34
|
class="pi pi-times rounded-full bg-slate-500 p-1 cursor-pointer text-xs"
|
|
@@ -78,9 +76,7 @@
|
|
|
78
76
|
>
|
|
79
77
|
<template #header>
|
|
80
78
|
<slot name="header">
|
|
81
|
-
<div
|
|
82
|
-
class="flex flex-row font font-semibold text-sm gap-2 p-2"
|
|
83
|
-
>
|
|
79
|
+
<div class="flex flex-row font font-semibold text-sm gap-2 p-2">
|
|
84
80
|
<div class="w w-1/3 line-clamp-1">
|
|
85
81
|
{{ t(codefield) ?? t("code") }}
|
|
86
82
|
</div>
|
|
@@ -128,14 +124,14 @@
|
|
|
128
124
|
<mobile-toolbar>
|
|
129
125
|
<template #start>
|
|
130
126
|
<ButtonText @click="mobileVisible = false">
|
|
131
|
-
<i class="pi pi-times"/>
|
|
127
|
+
<i class="pi pi-times" />
|
|
132
128
|
</ButtonText>
|
|
133
129
|
</template>
|
|
134
130
|
<template #center>
|
|
135
131
|
<TextTitle class="text-white">{{ t(docname) }}</TextTitle>
|
|
136
132
|
</template>
|
|
137
133
|
<template #end>
|
|
138
|
-
<div/>
|
|
134
|
+
<div />
|
|
139
135
|
<!-- <ButtonText @click="openViewer(false)">
|
|
140
136
|
<i class="pi pi-plus"></i>
|
|
141
137
|
</ButtonText> -->
|