UNPKG

stackpress

Version:

Incept is a content management framework.

20 lines (19 loc) 730 B
import update from '../actions/update.js'; export default function updateEventFactory(model) { return async function UpdateEventAction(req, res, ctx) { if (res.body || (res.code && res.code !== 200)) { return; } const engine = ctx.plugin('database'); if (!engine) return; const input = model.input(req.data(), false); const ids = Object.fromEntries(model.ids .map(column => [column.name, req.data(column.name)]) .filter(entry => Boolean(entry[1]))); const seed = ctx.config.path('database.seed'); const response = await update(model, engine, ids, input, seed); res.fromStatusResponse(response); }; } ;