UNPKG

@axway/api-builder-plugin-dc-mbs

Version:

Mobile Backend Services connector

27 lines (24 loc) 661 B
const { getTranslatedError } = require('../utils'); function deleteOne(Model, instance, next) { this.logger.trace('MBS.delete', { instance, model: Model.name }); this.db.customObjectsDelete({ classname: Model.name, id: instance.getPrimaryKey() }, (err, response) => { if (err) { // Do not expose `err` via callback (information disclosure) return next(getTranslatedError(this, err)); } if (response.body.meta.code === 200) { // return the affected instance this.logger.trace('MBS deleted', instance); return next(null, instance); } else { // not found return next(null); } }); } module.exports = { delete: deleteOne };