1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-12-17 23:27:48 +02:00
Files
joplin/packages/lib/models/MasterKey.ts

51 lines
1.3 KiB
TypeScript
Raw Normal View History

import BaseModel from '../BaseModel';
import { MasterKeyEntity } from '../services/database/types';
2021-06-26 18:18:10 +01:00
import { masterKeyAll, masterKeyById, saveMasterKey } from '../services/synchronizer/syncTargetInfoUtils';
import BaseItem from './BaseItem';
export default class MasterKey extends BaseItem {
static tableName() {
return 'master_keys';
}
static modelType() {
return BaseModel.TYPE_MASTER_KEY;
}
static encryptionSupported() {
return false;
}
static latest() {
2021-06-26 18:18:10 +01:00
throw new Error('Not implemented');
// return this.modelSelectOne('SELECT * FROM master_keys WHERE created_time >= (SELECT max(created_time) FROM master_keys)');
}
static allWithoutEncryptionMethod(masterKeys: MasterKeyEntity[], method: number) {
return masterKeys.filter(m => m.encryption_method !== method);
}
2021-06-26 18:18:10 +01:00
public static async load(id: string): Promise<MasterKeyEntity> {
return masterKeyById(id);
}
2021-07-02 17:25:27 +01:00
public static async allIds(): Promise<string[]> {
return masterKeyAll().map(k => k.id);
}
2021-06-26 18:18:10 +01:00
public static async all(): Promise<MasterKeyEntity[]> {
return masterKeyAll();
}
public static async save(o: MasterKeyEntity): Promise<MasterKeyEntity> {
const newMasterKey = saveMasterKey(o);
2021-07-02 17:25:27 +01:00
// this.dispatch({
// type: 'MASTERKEY_UPDATE_ONE',
// item: newMasterKey,
// });
2021-06-26 18:18:10 +01:00
return newMasterKey;
}
}