@punks/backend-entity-manager 0.0.189 → 0.0.190
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/cjs/index.js +9 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/integrations/cache/typeorm/instance.d.ts +3 -3
- package/dist/cjs/types/platforms/nest/__test__/server/infrastructure/cache/providers/default-instance/index.d.ts +2 -0
- package/dist/esm/index.js +9 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/integrations/cache/typeorm/instance.d.ts +3 -3
- package/dist/esm/types/platforms/nest/__test__/server/infrastructure/cache/providers/default-instance/index.d.ts +2 -0
- package/dist/index.d.ts +3 -3
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -2334,13 +2334,12 @@ const PlatformEvents = {
|
|
|
2334
2334
|
};
|
|
2335
2335
|
|
|
2336
2336
|
class TypeormCacheInstance {
|
|
2337
|
-
constructor(
|
|
2338
|
-
this.repository = repository;
|
|
2337
|
+
constructor(instanceName) {
|
|
2339
2338
|
this.instanceName = instanceName;
|
|
2340
2339
|
this.logger = backendCore.Log.getLogger(`TypeOrm Cache Instance ${instanceName}`);
|
|
2341
2340
|
}
|
|
2342
2341
|
async retrieve(key, input) {
|
|
2343
|
-
const item = await this.
|
|
2342
|
+
const item = await this.getRepository().findOne({
|
|
2344
2343
|
where: {
|
|
2345
2344
|
instance: this.instanceName,
|
|
2346
2345
|
key,
|
|
@@ -2354,7 +2353,7 @@ class TypeormCacheInstance {
|
|
|
2354
2353
|
return value;
|
|
2355
2354
|
}
|
|
2356
2355
|
async getAll() {
|
|
2357
|
-
const items = await this.
|
|
2356
|
+
const items = await this.getRepository().find({
|
|
2358
2357
|
where: {
|
|
2359
2358
|
instance: this.instanceName,
|
|
2360
2359
|
expirationTime: typeorm.MoreThanOrEqual(new Date()),
|
|
@@ -2363,7 +2362,7 @@ class TypeormCacheInstance {
|
|
|
2363
2362
|
return items.map((item) => item.data);
|
|
2364
2363
|
}
|
|
2365
2364
|
async get(key) {
|
|
2366
|
-
const item = await this.
|
|
2365
|
+
const item = await this.getRepository().findOne({
|
|
2367
2366
|
where: {
|
|
2368
2367
|
instance: this.instanceName,
|
|
2369
2368
|
key,
|
|
@@ -2373,8 +2372,8 @@ class TypeormCacheInstance {
|
|
|
2373
2372
|
return item?.data;
|
|
2374
2373
|
}
|
|
2375
2374
|
async set(key, { ttl, value }) {
|
|
2376
|
-
await this.
|
|
2377
|
-
const item = await manager.findOne(this.
|
|
2375
|
+
await this.getRepository().manager.transaction(async (manager) => {
|
|
2376
|
+
const item = await manager.findOne(this.getRepository().metadata.target, {
|
|
2378
2377
|
where: {
|
|
2379
2378
|
instance: this.instanceName,
|
|
2380
2379
|
key,
|
|
@@ -2388,7 +2387,7 @@ class TypeormCacheInstance {
|
|
|
2388
2387
|
this.logger.debug("Updated cache item", { key, value });
|
|
2389
2388
|
}
|
|
2390
2389
|
else {
|
|
2391
|
-
const newItem = this.
|
|
2390
|
+
const newItem = this.getRepository().create({
|
|
2392
2391
|
id: backendCore.newUuid(),
|
|
2393
2392
|
instance: this.instanceName,
|
|
2394
2393
|
key,
|
|
@@ -2401,14 +2400,14 @@ class TypeormCacheInstance {
|
|
|
2401
2400
|
});
|
|
2402
2401
|
}
|
|
2403
2402
|
async delete(key) {
|
|
2404
|
-
await this.
|
|
2403
|
+
await this.getRepository().delete({
|
|
2405
2404
|
instance: this.instanceName,
|
|
2406
2405
|
key,
|
|
2407
2406
|
});
|
|
2408
2407
|
this.logger.debug("Deleted cache item", { key });
|
|
2409
2408
|
}
|
|
2410
2409
|
async clear() {
|
|
2411
|
-
await this.
|
|
2410
|
+
await this.getRepository().delete({
|
|
2412
2411
|
instance: this.instanceName,
|
|
2413
2412
|
});
|
|
2414
2413
|
this.logger.debug("Cleared cache");
|