Zusätzliche Felder

This commit is contained in:
2020-03-02 16:27:31 +01:00
committed by smuddy
parent 53a234458f
commit f5d9350e53
36 changed files with 357 additions and 74 deletions

View File

@@ -1,6 +1,9 @@
import {Injectable} from '@angular/core';
import {SongDataService} from './song-data.service';
import {File} from './file';
import {Observable} from 'rxjs';
import {map} from 'rxjs/operators';
import {FileServer} from './fileServer';
@Injectable({
providedIn: 'root'
@@ -10,10 +13,22 @@ export class FileDataService {
constructor(private songDataService: SongDataService) {
}
public async put(songId: string, file: File): Promise<string> {
public async put(songId: string, file: FileServer): Promise<string> {
const songRef = this.songDataService.getSongRef(songId);
const fileCollection = songRef.collection('files');
const id = await fileCollection.add(file);
return id.id;
}
public get$(songId: string): Observable<File[]> {
const songRef = this.songDataService.getSongRef(songId);
return songRef.collection<File>('files').snapshotChanges().pipe(map(actions => {
return actions.map(a => ({
...a.payload.doc.data(),
id: a.payload.doc.id
}));
}));
}
}