@punks/backend-entity-manager 0.0.189 → 0.0.191
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 +12 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/cache.d.ts +1 -0
- package/dist/cjs/types/integrations/cache/typeorm/instance.d.ts +4 -3
- package/dist/cjs/types/platforms/nest/__test__/server/infrastructure/cache/providers/default-instance/index.d.ts +2 -0
- package/dist/esm/index.js +12 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/cache.d.ts +1 -0
- package/dist/esm/types/integrations/cache/typeorm/instance.d.ts +4 -3
- package/dist/esm/types/platforms/nest/__test__/server/infrastructure/cache/providers/default-instance/index.d.ts +2 -0
- package/dist/index.d.ts +5 -3
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -2334,13 +2334,15 @@ 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
|
}
|
|
2341
|
+
getInstanceName() {
|
|
2342
|
+
return this.instanceName;
|
|
2343
|
+
}
|
|
2342
2344
|
async retrieve(key, input) {
|
|
2343
|
-
const item = await this.
|
|
2345
|
+
const item = await this.getRepository().findOne({
|
|
2344
2346
|
where: {
|
|
2345
2347
|
instance: this.instanceName,
|
|
2346
2348
|
key,
|
|
@@ -2354,7 +2356,7 @@ class TypeormCacheInstance {
|
|
|
2354
2356
|
return value;
|
|
2355
2357
|
}
|
|
2356
2358
|
async getAll() {
|
|
2357
|
-
const items = await this.
|
|
2359
|
+
const items = await this.getRepository().find({
|
|
2358
2360
|
where: {
|
|
2359
2361
|
instance: this.instanceName,
|
|
2360
2362
|
expirationTime: typeorm.MoreThanOrEqual(new Date()),
|
|
@@ -2363,7 +2365,7 @@ class TypeormCacheInstance {
|
|
|
2363
2365
|
return items.map((item) => item.data);
|
|
2364
2366
|
}
|
|
2365
2367
|
async get(key) {
|
|
2366
|
-
const item = await this.
|
|
2368
|
+
const item = await this.getRepository().findOne({
|
|
2367
2369
|
where: {
|
|
2368
2370
|
instance: this.instanceName,
|
|
2369
2371
|
key,
|
|
@@ -2373,8 +2375,8 @@ class TypeormCacheInstance {
|
|
|
2373
2375
|
return item?.data;
|
|
2374
2376
|
}
|
|
2375
2377
|
async set(key, { ttl, value }) {
|
|
2376
|
-
await this.
|
|
2377
|
-
const item = await manager.findOne(this.
|
|
2378
|
+
await this.getRepository().manager.transaction(async (manager) => {
|
|
2379
|
+
const item = await manager.findOne(this.getRepository().metadata.target, {
|
|
2378
2380
|
where: {
|
|
2379
2381
|
instance: this.instanceName,
|
|
2380
2382
|
key,
|
|
@@ -2388,7 +2390,7 @@ class TypeormCacheInstance {
|
|
|
2388
2390
|
this.logger.debug("Updated cache item", { key, value });
|
|
2389
2391
|
}
|
|
2390
2392
|
else {
|
|
2391
|
-
const newItem = this.
|
|
2393
|
+
const newItem = this.getRepository().create({
|
|
2392
2394
|
id: backendCore.newUuid(),
|
|
2393
2395
|
instance: this.instanceName,
|
|
2394
2396
|
key,
|
|
@@ -2401,14 +2403,14 @@ class TypeormCacheInstance {
|
|
|
2401
2403
|
});
|
|
2402
2404
|
}
|
|
2403
2405
|
async delete(key) {
|
|
2404
|
-
await this.
|
|
2406
|
+
await this.getRepository().delete({
|
|
2405
2407
|
instance: this.instanceName,
|
|
2406
2408
|
key,
|
|
2407
2409
|
});
|
|
2408
2410
|
this.logger.debug("Deleted cache item", { key });
|
|
2409
2411
|
}
|
|
2410
2412
|
async clear() {
|
|
2411
|
-
await this.
|
|
2413
|
+
await this.getRepository().delete({
|
|
2412
2414
|
instance: this.instanceName,
|
|
2413
2415
|
});
|
|
2414
2416
|
this.logger.debug("Cleared cache");
|