文件
mynode/packages/lib/models/ConflictNoteState.ts
chen 301194963b
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
feat: Initial clean release of CHM
2026-11-04 11:29:39 +08:00

39 行
1.3 KiB
TypeScript

import BaseModel from '../BaseModel';
import { ConflictNoteStateEntity } from '../services/database/types';
// Keyed by the conflict note id. The remote note only stores it's updated_time
// to track later changes. remote_title and remote_body are kept for future
// partial conflict resolution.
export default class ConflictNoteState extends BaseModel {
public static tableName() {
return 'conflict_note_states';
}
public static modelType() {
return BaseModel.TYPE_CONFLICT_NOTE_STATE;
}
public static async byNoteId(noteId: string): Promise<ConflictNoteStateEntity> {
return this.db().selectOne('SELECT * FROM conflict_note_states WHERE note_id = ?', [noteId]);
}
public static async deleteByNoteIds(noteIds: string[]) {
if (!noteIds.length) return;
await this.db().exec(`DELETE FROM conflict_note_states WHERE note_id IN (${noteIds.map(() => '?').join(',')})`, noteIds);
}
public static async save(state: ConflictNoteStateEntity) {
await this.db().exec(
'INSERT OR REPLACE INTO conflict_note_states (note_id, base_body, base_title, remote_body, remote_title, remote_updated_time) VALUES (?, ?, ?, ?, ?, ?)',
[
state.note_id,
state.base_body ?? '',
state.base_title ?? '',
state.remote_body ?? '',
state.remote_title ?? '',
state.remote_updated_time ?? 0,
],
);
}
}