mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-11 15:22:43 +01:00
tabs on tabs??
moving storage/model/stuff around
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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' });
|
||||
|
||||
Reference in New Issue
Block a user