@dudousxd/nestjs-durable-store-mikro-orm 0.33.6 → 0.33.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1176,22 +1176,25 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
1176
1176
  });
1177
1177
  }
1178
1178
  async createRun(run) {
1179
- const em = this.fork();
1180
- em.create(WorkflowRunEntity, toRunEntity(run));
1181
- await em.flush();
1179
+ await this.fork().insert(WorkflowRunEntity, toRunEntity(run));
1182
1180
  await this.reindexAttributes(run.id, run.searchAttributes);
1183
1181
  }
1184
1182
  async updateRun(runId, inputPatch) {
1185
1183
  const patch = inputPatch.status && import_nestjs_durable_core.TERMINAL_RUN_STATUSES.includes(inputPatch.status) ? await (0, import_nestjs_durable_core.clearTerminalSingletonAdmission)(runId, inputPatch, (id) => this.withScope({}).getRun(id)) : inputPatch;
1184
+ const data = runUpdateData(patch);
1186
1185
  const em = this.fork();
1187
- const entity = await em.findOneOrFail(WorkflowRunEntity, {
1188
- id: runId
1189
- });
1190
- Object.assign(entity, toRunEntity({
1191
- ...fromRunEntity(entity),
1192
- ...patch
1193
- }));
1194
- await em.flush();
1186
+ if (Object.keys(data).length) {
1187
+ const affected = await em.nativeUpdate(WorkflowRunEntity, {
1188
+ id: runId
1189
+ }, data);
1190
+ if (affected === 0) await em.findOneOrFail(WorkflowRunEntity, {
1191
+ id: runId
1192
+ });
1193
+ } else {
1194
+ await em.findOneOrFail(WorkflowRunEntity, {
1195
+ id: runId
1196
+ });
1197
+ }
1195
1198
  if ("searchAttributes" in patch) await this.reindexAttributes(runId, patch.searchAttributes);
1196
1199
  }
1197
1200
  async updateRunIf(runId, expectedStatuses, inputPatch) {