@simitgroup/simpleapp-generator 1.6.7-j-alpha → 1.6.7-k-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,8 @@
1
+ [1.6.7k-alpha]
2
+
3
+ 1. Add More Setter For User Context
4
+ 2. Fix createManyWithId No Use Session
5
+
1
6
  [1.6.7j-alpha]
2
7
 
3
8
  1. Add Custom Field Constant File For Mini Api
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simitgroup/simpleapp-generator",
3
- "version": "1.6.7j-alpha",
3
+ "version": "1.6.7k-alpha",
4
4
  "description": "frontend nuxtjs and backend nests code generator using jsonschema",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -241,6 +241,22 @@ export class UserContext {
241
241
  this.package = packageName;
242
242
  };
243
243
 
244
+ setTimeZone = (timeZone: string) => {
245
+ this.timeZone = timeZone;
246
+ };
247
+
248
+ setCountry = (country: string) => {
249
+ this.country = country;
250
+ };
251
+
252
+ setCurrency = (currency: string) => {
253
+ this.currency = currency;
254
+ };
255
+
256
+ setOffsetMinute = (offsetMinute: number) => {
257
+ this.offsetMinute = offsetMinute;
258
+ };
259
+
244
260
  /**
245
261
  * Obtain user profile filter by uid, tenantId, orgId, branchId
246
262
  * @returns Promise<User|undefined>
@@ -96,7 +96,7 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
96
96
  public isReadOnly(): boolean {
97
97
  return false;
98
98
  }
99
- reCalculateValue(data: T) { }
99
+ reCalculateValue(data: T) {}
100
100
  getIsolationFilter = (appuser: UserContext) => {
101
101
  let isolationFilter = {};
102
102
  switch (this.isolationtype) {
@@ -338,6 +338,11 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
338
338
 
339
339
  async createManyWithId(appuser: UserContext, datas: T[]) {
340
340
  if (Array.isArray(datas)) {
341
+ const dbsession = appuser.getDBSession();
342
+ if (dbsession && !dbsession.inTransaction()) {
343
+ dbsession.startTransaction({ readPreference: 'primary' });
344
+ }
345
+
341
346
  for (let i = 0; i < datas.length; i++) {
342
347
  const data = datas[i];
343
348
  let isolationFilter: any = { ...appuser.getCreateFilterWithId() };
@@ -349,8 +354,11 @@ export class SimpleAppService<T extends { _id?: string; __v?: number }> {
349
354
  this.applyNestedDateTime(appuser, data, 'create');
350
355
  }
351
356
 
352
- const result = await this.doc.insertMany(datas);
357
+ const result = await this.doc.insertMany(datas, { session: dbsession });
353
358
  await this.audittrail.addManyEvents(appuser, this.documentName, 'createMany', datas);
359
+ for (let i = 0; i < datas.length; i++) {
360
+ appuser.addInsertedRecordId(this.documentName, datas[i]._id);
361
+ }
354
362
  return result;
355
363
  } else {
356
364
  throw new BadRequestException(this.getDocumentType() + ': create many only support array');