Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@decaf-ts/db-decorators

Package Overview
Dependencies
Maintainers
0
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@decaf-ts/db-decorators - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

2

lib/esm/repository/Repository.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc