rez_core 4.0.244 → 4.0.246
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/dist/module/entity_json/entity_json.module.js +2 -1
- package/dist/module/entity_json/entity_json.module.js.map +1 -1
- package/dist/module/entity_json/service/entityJson.repository.d.ts +1 -1
- package/dist/module/entity_json/service/entityJson.repository.js +12 -1
- package/dist/module/entity_json/service/entityJson.repository.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/entity_json/entity_json.module.ts +2 -1
- package/src/module/entity_json/service/entityJson.repository.ts +25 -4
package/package.json
CHANGED
|
@@ -6,11 +6,12 @@ import { EntityJSONController } from './controller/entity_json.controller';
|
|
|
6
6
|
import { FilterModule } from '../filter/filter.module';
|
|
7
7
|
import { UtilsModule } from 'src/utils/utils.module';
|
|
8
8
|
import { EntityJson } from './entity/entityJson.entity';
|
|
9
|
+
import { EntityJSONRepository } from './service/entityJson.repository';
|
|
9
10
|
|
|
10
11
|
@Module({
|
|
11
12
|
imports: [EntityModule, TypeOrmModule.forFeature([EntityJson]),FilterModule,UtilsModule],
|
|
12
13
|
controllers: [EntityJSONController],
|
|
13
|
-
providers: [EntityJSONService],
|
|
14
|
+
providers: [EntityJSONService,EntityJSONRepository],
|
|
14
15
|
exports: [],
|
|
15
16
|
})
|
|
16
17
|
export class EntityJSONModule {}
|
|
@@ -8,9 +8,30 @@ import { create } from "domain";
|
|
|
8
8
|
@Injectable()
|
|
9
9
|
export class EntityJSONRepository {
|
|
10
10
|
constructor(
|
|
11
|
-
@InjectRepository(EntityJson)
|
|
11
|
+
@InjectRepository(EntityJson)
|
|
12
|
+
private readonly entityJSONRepository: Repository<EntityJson>,
|
|
12
13
|
) {}
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
async create(flatJson: Partial<EntityJson>) {
|
|
16
|
+
const { entity_type, entity_id } = flatJson;
|
|
17
|
+
|
|
18
|
+
// Step 1 — check if exists by unique keys
|
|
19
|
+
const existing = await this.entityJSONRepository.findOne({
|
|
20
|
+
where: { entity_type, entity_id },
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
if (existing) {
|
|
24
|
+
// Step 2 — normal update (no merge)
|
|
25
|
+
await this.entityJSONRepository.update(existing.id, flatJson);
|
|
26
|
+
|
|
27
|
+
// Optionally return updated row (common practice)
|
|
28
|
+
return this.entityJSONRepository.findOne({
|
|
29
|
+
where: { id: existing.id },
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Step 3 — insert new
|
|
34
|
+
const created = this.entityJSONRepository.create(flatJson);
|
|
35
|
+
return this.entityJSONRepository.save(created);
|
|
36
|
+
}
|
|
15
37
|
}
|
|
16
|
-
}
|