Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

fix: sendtopic after error happened #101

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: return entity when create
  • Loading branch information
yoution committed Jul 27, 2021
commit 144a8c1575cdf2595a93ced79200efd734db7b11
5 changes: 3 additions & 2 deletions src/modules/user/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ const uniqueFields = [['handle']]
async function create (entity, auth) {
await dbHelper.makeSureUnique(User, entity, uniqueFields)

let payload
let payload
try {
const result = await sequelize.transaction(async (t) => {
const userEntity = await dbHelper.create(User, entity, auth, t)
payload = userEntity.dataValues
await serviceHelper.createRecordInEs(resource, userEntity.dataValues, true)
return userEntity
})
return result
} catch (e) {
Expand Down Expand Up @@ -200,7 +201,7 @@ async function beginCascadeDelete (id, params) {
await dbHelper.remove(User, id, null, t)
await serviceHelper.deleteRecordFromEs(id, params, resource, true)
})

} catch (e) {
helper.postEvent(config.UBAHN_DELETE_USER_TOPIC, payload)
throw e
Expand Down