@decaf-ts/db-decorators
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -1,1 +0,1 @@ | ||
import{enforceDBDecorators}from"./utils";import{OperationKeys}from"../operations/constants";import{ConflictError,NotFoundError,ValidationError}from"./errors";import{BaseRepository}from"./BaseRepository";import{findModelId}from"../identity";import{sf}from"@decaf-ts/decorator-validation";class Repository extends BaseRepository{constructor(r){super(r)}async create(r){throw new Error("Child classes must implement this.")}async createPrefix(t,...e){t=new this.class(t),await enforceDBDecorators(this,t,OperationKeys.CREATE,OperationKeys.ON);var r=t.hasErrors();if(r)throw new ValidationError(r.toString());let o;try{if(!(o=findModelId(t,!0)))return[t,...e];o&&await this.read(o.toString())}catch(r){if(r instanceof NotFoundError)return[t,...e];throw r}throw new ConflictError(sf("Model with id {0} already exists",o))}async delete(r){throw new Error("Child classes must implement this.")}async deletePrefix(r,...t){var e=new this.class;return await enforceDBDecorators(this,e,OperationKeys.DELETE,OperationKeys.ON),[r,...t]}async read(r){throw new Error("Child classes must implement this.")}async update(r){throw new Error("Child classes must implement this.")}async updatePrefix(r,...t){r=new this.class(r);var e=findModelId(r),e=await this.read(e),e=(await enforceDBDecorators(this,r,OperationKeys.UPDATE,OperationKeys.ON,e),r.hasErrors(e));if(e)throw new ValidationError(e.toString());return[r,...t]}}export{Repository}; | ||
import{enforceDBDecorators}from"./utils";import{OperationKeys}from"../operations/constants";import{ValidationError}from"./errors";import{BaseRepository}from"./BaseRepository";import{findModelId}from"../identity";class Repository extends BaseRepository{constructor(r){super(r)}async create(r){throw new Error("Child classes must implement this.")}async createPrefix(r,...e){r=new this.class(r),await enforceDBDecorators(this,r,OperationKeys.CREATE,OperationKeys.ON);var t=r.hasErrors();if(t)throw new ValidationError(t.toString());return[r,...e]}async delete(r){throw new Error("Child classes must implement this.")}async deletePrefix(r,...e){var t=new this.class;return await enforceDBDecorators(this,t,OperationKeys.DELETE,OperationKeys.ON),[r,...e]}async read(r){throw new Error("Child classes must implement this.")}async update(r){throw new Error("Child classes must implement this.")}async updatePrefix(r,...e){r=new this.class(r);var t=findModelId(r),t=await this.read(t),t=(await enforceDBDecorators(this,r,OperationKeys.UPDATE,OperationKeys.ON,t),r.hasErrors(t));if(t)throw new ValidationError(t.toString());return[r,...e]}}export{Repository}; |
{ | ||
"name": "@decaf-ts/db-decorators", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Agnostic database decorators and repository", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
308501
12
26