From 4198246351a64c3f3c0cd05bbd1e7146d95fcd32 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 12 Apr 2019 01:30:10 +0900 Subject: トランザクションを使用してアンケートレコードの挿入に失敗した場合に投稿レコードの挿入もなかったことにするように MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/entities/note.ts | 8 ++++++++ src/models/entities/poll.ts | 8 ++++++++ 2 files changed, 16 insertions(+) (limited to 'src/models') diff --git a/src/models/entities/note.ts b/src/models/entities/note.ts index 176fc626b3..6c7aebdd0d 100644 --- a/src/models/entities/note.ts +++ b/src/models/entities/note.ts @@ -214,6 +214,14 @@ export class Note { }) public renoteUserHost: string | null; //#endregion + + constructor(data: Partial) { + if (data == null) return; + + for (const [k, v] of Object.entries(data)) { + (this as any)[k] = v; + } + } } export type IMentionedRemoteUsers = { diff --git a/src/models/entities/poll.ts b/src/models/entities/poll.ts index 894f07e689..c0ad5547bd 100644 --- a/src/models/entities/poll.ts +++ b/src/models/entities/poll.ts @@ -53,6 +53,14 @@ export class Poll { }) public userHost: string | null; //#endregion + + constructor(data: Partial) { + if (data == null) return; + + for (const [k, v] of Object.entries(data)) { + (this as any)[k] = v; + } + } } export type IPoll = { -- cgit v1.2.3-freya