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 1.0.1 to 1.1.0

4

CHANGELOG.md

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

## [1.1.0] - 2019-06-28
### Added
- ApiSaveData now accepts a `format()` hook to manipulate main data before saving
## [1.0.1] - 2019-06-27

@@ -12,0 +16,0 @@ ### Changed

@@ -29,2 +29,5 @@ 'use strict';

if(this.format)
this.dataToSave.main = this.format(this.dataToSave.main);
const apiSaveMain = new ApiSaveMain(this);

@@ -31,0 +34,0 @@ const savedId = await apiSaveMain.process();

2

package.json
{
"name": "@janiscommerce/api-save",
"version": "1.0.1",
"version": "1.1.0",
"description": "A package to handle JANIS Views Save APIs",

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

@@ -17,9 +17,43 @@ # API Save

const { ApiSave } = require('@janiscommerce/api-save');
const { ApiSaveData } = require('@janiscommerce/api-save');
const { Controller } = require('@janiscommerce/model-controller');
const { struct } = require('superstruct');
class MyApiSave extends ApiSave {
class MyApiSaveData extends ApiSaveData {
static get relationshipsParameters() {
return {
children: {
controller: Controller.getInstance('some-relationship-entity'),
mainIdentifierField: 'dbFieldForMainEntity',
secondaryIdentifierField: 'dbFieldForRelatedEntity',
shouldClean: false
}
};
}
getStruct() {
return struct({
id: 'number',
data: struct.partial({
name: 'string',
description: 'string?',
status: 'number'
}),
relationships: struct.partial({
children: ['number']
})
});
}
format({ someField, ...restoOfTheRecord }) {
return {
...restoOfTheRecord,
someField: `prefix-${someField}`
};
}
}
module.exports = MyApiSave;
module.exports = MyApiSaveData;
```
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