Skip to content

Commit

Permalink
fix: new action populates record before returning
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtek-krysiak committed Oct 12, 2020
1 parent 323ea9a commit 19dd439
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/backend/actions/new/new-action.ts
@@ -1,3 +1,4 @@
import { populator } from '../../utils'
import { Action, RecordActionResponse } from '../action.interface'

/**
Expand Down Expand Up @@ -29,10 +30,13 @@ export const NewAction: Action<RecordActionResponse> = {
const { resource, h, currentAdmin, translateMessage } = context
if (request.method === 'post') {
let record = await resource.build(request.payload ? request.payload : {})

record = await record.save()
const [populatedRecord] = await populator([record])

// eslint-disable-next-line no-param-reassign
context.record = record
context.record = populatedRecord


if (record.isValid()) {
return {
Expand Down

0 comments on commit 19dd439

Please sign in to comment.