tabs on tabs??

moving storage/model/stuff around
This commit is contained in:
austinried
2021-06-19 11:32:23 +09:00
parent d41fb5b9e7
commit f19cbabac4
34 changed files with 355 additions and 73 deletions

View File

@@ -1,3 +1,4 @@
import { Artist } from '../models/music';
import { DbStorage } from './db';
export class MusicDb extends DbStorage {
@@ -16,4 +17,27 @@ export class MusicDb extends DbStorage {
`);
});
}
async getArtists(): Promise<Artist[]> {
return (await this.executeSql(`
SELECT * FROM artists;
`))[0].rows.raw().map(x => ({
id: x.id,
name: x.name,
}));
}
async updateArtists(artists: Artist[]): Promise<void> {
await this.transaction((tx) => {
tx.executeSql(`
DELETE FROM artists
`);
for (const a of artists) {
tx.executeSql(`
INSERT INTO artists (id, name, starred)
VALUES (?, ?, ?);
`, [a.id, a.name, false]);
}
});
}
}

View File

@@ -1,17 +1,6 @@
import { AppSettings, ServerSettings } from '../models/settings';
import { DbStorage } from './db';
export interface ServerSettings {
id: string;
address: string;
username: string;
token: string;
salt: string;
}
export interface AppSettings {
server?: string;
}
export class SettingsDb extends DbStorage {
constructor() {
super({ name: 'settings.db', location: 'Library' });