create new title

This commit is contained in:
2020-05-03 11:54:12 +02:00
committed by smuddy
parent ea39208840
commit ca661e3da9
13 changed files with 185 additions and 4 deletions

View File

@@ -7,11 +7,14 @@ import {DbService} from '../../../services/db.service';
providedIn: 'root'
})
export class SongDataService {
private collection = 'songs';
constructor(private dbService: DbService) {
}
public list$ = (): Observable<Song[]> => this.dbService.col$('songs');
public read$ = (songId: string): Observable<Song | undefined> => this.dbService.doc$('songs/' + songId);
public update$ = async (songId: string, data: any): Promise<void> => await this.dbService.doc('songs/' + songId).update(data);
public list$ = (): Observable<Song[]> => this.dbService.col$(this.collection);
public read$ = (songId: string): Observable<Song | undefined> => this.dbService.doc$(this.collection + '/' + songId);
public update$ = async (songId: string, data: Partial<Song>): Promise<void> => await this.dbService.doc(this.collection + '/' + songId).update(data);
public add = async (data: Partial<Song>): Promise<string> => (await this.dbService.col(this.collection).add(data)).id
}

View File

@@ -32,6 +32,10 @@ export class SongService {
await this.songDataService.update$(songId, data);
}
public async new(number: number, title: string): Promise<string> {
return await this.songDataService.add({number, title, status: 'draft', legalType: 'open'})
}
// https://www.csvjson.com/csv2json
private async updateFromCLI(songs: Song[]) {
const mapped = songs.map(_ => ({