parsing words fields
This commit is contained in:
1 parent
b76d115d7e
commit
8a0834abac
1 file changed
+13
-4
+13
-4
@@ -38,20 +38,29 @@ export interface Word {
|
|||||||
key: string;
|
key: string;
|
||||||
value: string;
|
value: string;
|
||||||
tags: string;
|
tags: string;
|
||||||
more: string | null;
|
more: Map<number, string>;
|
||||||
group_id: number;
|
group_id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function wordList() {
|
export async function wordList() {
|
||||||
let rows = await query("SELECT id, key, value, tags, more, group_id FROM words");
|
let rows = await query("SELECT id, key, value, tags, more, group_id FROM words");
|
||||||
return rows.map((row: any) => ({
|
|
||||||
|
return rows.map((row: any) => {
|
||||||
|
let more : string = row.more.split('');
|
||||||
|
let dict = new Map();
|
||||||
|
for (let i = 0; i < more.length / 2; i++) {
|
||||||
|
dict.set(more[i * 2], more[i * 2 + 1]);
|
||||||
|
}
|
||||||
|
let w = {
|
||||||
id: row.id,
|
id: row.id,
|
||||||
key: row.key,
|
key: row.key,
|
||||||
value: row.value,
|
value: row.value,
|
||||||
tags: row.tags,
|
tags: row.tags,
|
||||||
more: row.more,
|
more: dict,
|
||||||
group_id: row.group_id,
|
group_id: row.group_id,
|
||||||
})) as Word[];
|
}
|
||||||
|
return w;
|
||||||
|
}) as Word[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HistoryEntry {
|
export interface HistoryEntry {
|
||||||
|
|||||||
Reference in new issue
Block a user