@travetto/model-redis 5.0.17 → 5.0.18
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/LICENSE +1 -1
- package/package.json +4 -4
- package/src/service.ts +3 -3
- package/support/service.redis.ts +1 -1
package/LICENSE
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-redis",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.18",
|
|
4
4
|
"description": "Redis backing for the travetto model module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"directory": "module/model-redis"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@travetto/cli": "^5.0.
|
|
29
|
-
"@travetto/config": "^5.0.
|
|
30
|
-
"@travetto/model": "^5.0.
|
|
28
|
+
"@travetto/cli": "^5.0.17",
|
|
29
|
+
"@travetto/config": "^5.0.14",
|
|
30
|
+
"@travetto/model": "^5.0.15",
|
|
31
31
|
"redis": "^4.7.0"
|
|
32
32
|
},
|
|
33
33
|
"travetto": {
|
package/src/service.ts
CHANGED
|
@@ -187,11 +187,11 @@ export class RedisModelService implements ModelCrudSupport, ModelExpirySupport,
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
async has<T extends ModelType>(cls: Class<T>, id: string, error?: 'notfound' | '
|
|
190
|
+
async has<T extends ModelType>(cls: Class<T>, id: string, error?: 'notfound' | 'exists'): Promise<void> {
|
|
191
191
|
const res = await this.client.exists(this.#resolveKey(cls, id));
|
|
192
192
|
if (res === 0 && error === 'notfound') {
|
|
193
193
|
throw new NotFoundError(cls, id);
|
|
194
|
-
} else if (res === 1 && error === '
|
|
194
|
+
} else if (res === 1 && error === 'exists') {
|
|
195
195
|
throw new ExistsError(cls, id);
|
|
196
196
|
}
|
|
197
197
|
}
|
|
@@ -209,7 +209,7 @@ export class RedisModelService implements ModelCrudSupport, ModelExpirySupport,
|
|
|
209
209
|
|
|
210
210
|
async create<T extends ModelType>(cls: Class<T>, item: OptionalId<T>): Promise<T> {
|
|
211
211
|
if (item.id) {
|
|
212
|
-
await this.has(cls, item.id, '
|
|
212
|
+
await this.has(cls, item.id, 'exists');
|
|
213
213
|
}
|
|
214
214
|
const prepped = await ModelCrudUtil.preStore(cls, item, this);
|
|
215
215
|
await this.#store(cls, prepped, 'write');
|
package/support/service.redis.ts
CHANGED