@simitgroup/simpleapp-generator 2.0.1-p-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,9 @@
1
+ [2.0.1q-alpha]
2
+
3
+ 1. fixagain delete record cant work in transactions, sharded env
4
+
5
+
6
+
1
7
  [2.0.1p-alpha]
2
8
 
3
9
  1. fix delete record cant work in transactions, sharded env
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simitgroup/simpleapp-generator",
3
- "version": "2.0.1p-alpha",
3
+ "version": "2.0.1q-alpha",
4
4
  "description": "frontend nuxtjs and backend nests code generator using jsonschema",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -559,7 +559,7 @@ export class SimpleAppService<T extends SchemaFields> {
559
559
 
560
560
  // if (this.hooks.beforeDelete) await this.hooks.beforeDelete(appuser, id, deletedata);
561
561
  this.logger.debug('delete record', this.documentName, id);
562
- await this.identifyForeignKeys(appuser,deletedata)
562
+ dependency = await this.getRelatedRecords(appuser, id);
563
563
  if (!dependency) {
564
564
  const filterIsolation = this.getIsolationFilter(appuser);
565
565
  this.polishIsolationFilter(filterIsolation);
@@ -780,21 +780,20 @@ export class SimpleAppService<T extends SchemaFields> {
780
780
  throw new InternalServerErrorException(err.message);
781
781
  }
782
782
  };
783
- async deleteMany(appUser:UserContext, filter: FilterQuery<T>){
783
+ async deleteMany(appUser: UserContext, filter: FilterQuery<T>) {
784
784
  const dbsession = appUser.getDBSession();
785
785
  if (dbsession && !dbsession.inTransaction()) {
786
786
  dbsession.startTransaction({ readConcern: { level: 'snapshot' }, writeConcern: { w: 'majority' }, readPreference: 'primary' });
787
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)
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
794
  }
795
- return result
795
+ return result;
796
796
  //updateMany(isolationFilter, { $set: patch }, { session: dbsession });
797
-
798
797
  }
799
798
  async patchMany<T>(appuser: UserContext, data: PatchManyRequest<T>) {
800
799
  // filter = {
@@ -849,10 +848,14 @@ export class SimpleAppService<T extends SchemaFields> {
849
848
  //not deleted in current session, check from database
850
849
  const filter = {};
851
850
  filter[fkey] = id;
852
- const result = await collection.findOne(filter, {
851
+ const result:any = await collection.findOne(filter, {
853
852
  session: appuser.getDBSession(),
854
853
  });
855
854
  if (result) {
855
+ //record deleted but not yet commit, safely ignore
856
+ if(appuser.searchDeletedRecordId(collectionname, result._id))continue;
857
+
858
+
856
859
  this.logger.error(result, `related result found in ${collectionname} ${fkey} = ${id}`);
857
860
  return result;
858
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> -->