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

@janiscommerce/api-save

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@janiscommerce/api-save - npm Package Compare versions

Comparing version 3.0.1 to 3.0.2

6

CHANGELOG.md

@@ -10,2 +10,8 @@ # Changelog

## [3.0.2] - 2019-09-30
### Fixed
- README fixed for relationship models property `modelClass`
- Relationships are now saved properly
- Empty relationships now works as expected instead of throwing an error
## [3.0.1] - 2019-08-06

@@ -12,0 +18,0 @@ ### Fixed

2

lib/api-save-data.js

@@ -63,3 +63,3 @@ 'use strict';

} catch(e) {
throw new ApiSaveError(e.message, ApiSaveError.codes.INTERNAL_ERROR);
throw new ApiSaveError(e.message, ApiSaveError.codes.INTERNAL_ERROR, e);
}

@@ -66,0 +66,0 @@ }

@@ -15,3 +15,3 @@ 'use strict';

constructor(err, code) {
constructor(err, code, previousError) {
super(err);

@@ -21,2 +21,5 @@ this.message = err.message || err;

this.name = 'ApiSaveError';
if(previousError)
this.previousError = previousError;
}

@@ -23,0 +26,0 @@ }

@@ -39,7 +39,11 @@ 'use strict';

if(!relationshipsToSave.length)
return Promise.resolve();
const model = this.apiInstance.client ? this.apiInstance.client.getInstance(ModelClass) : new ModelClass();
return model.multiInsert(relationshipsToSave);
}
insertAndRemove(relationship, relationshipParameters) {
async insertAndRemove(relationship, relationshipParameters) {

@@ -49,3 +53,3 @@ const { modelClass: ModelClass, mainIdentifierField } = relationshipParameters;

const model = this.apiInstance.client ? this.apiInstance.client.getInstance(ModelClass) : new ModelClass();
const currentRelationships = model.get({
const currentRelationships = await model.get({
[mainIdentifierField]: this.mainId

@@ -52,0 +56,0 @@ });

@@ -39,3 +39,3 @@ 'use strict';

const errorPath = e.path.join('.');
throw new ApiSaveError(`${e.message} in ${errorPath}`, ApiSaveError.codes.INVALID_REQUEST_DATA);
throw new ApiSaveError(`${e.message} in ${errorPath}`, ApiSaveError.codes.INVALID_REQUEST_DATA, e);
}

@@ -48,3 +48,3 @@ }

} catch(e) {
throw new ApiSaveError(e.message, ApiSaveError.codes.INVALID_ENTITY);
throw new ApiSaveError(e.message, ApiSaveError.codes.INVALID_ENTITY, e);
}

@@ -51,0 +51,0 @@ }

{
"name": "@janiscommerce/api-save",
"version": "3.0.1",
"version": "3.0.2",
"description": "A package to handle JANIS Views Save APIs",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -27,3 +27,3 @@ # API Save

children: {
ModelClass: MyRelatedModel,
modelClass: MyRelatedModel,
mainIdentifierField: 'dbFieldForMainEntity',

@@ -77,3 +77,3 @@ secondaryIdentifierField: 'dbFieldForRelatedEntity',

The parameters contain the following properties:
- ModelClass: The class of the model that should save this relationship
- modelClass: The class of the model that should save this relationship
- mainIdentifierField: The field name where the main ID should be saved

@@ -80,0 +80,0 @@ - secondaryIdentifierField: The field name where the related ID should be saved

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