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

A package to handle JANIS Views Save APIs

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
304
decreased by-22.25%
Maintainers
1
Weekly downloads
 
Created
Source

API Save

Build Status Coverage Status

A package to handle JANIS Views Save APIs

Installation

npm install @janiscommerce/api-save

Usage

'use strict';

const { ApiSaveData } = require('@janiscommerce/api-save');
const { Controller } = require('@janiscommerce/model-controller');
const { struct } = require('superstruct');

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 = MyApiSaveData;

FAQs

Package last updated on 28 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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