add song to show
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
|
||||
import {ShowSongDataService} from './show-song-data.service';
|
||||
|
||||
describe('ShowSongDataService', () => {
|
||||
let service: ShowSongDataService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ShowSongDataService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
20
src/app/modules/shows/services/show-song-data.service.ts
Normal file
20
src/app/modules/shows/services/show-song-data.service.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {DbService} from '../../../services/db.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {ShowSong} from './showSong';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ShowSongDataService {
|
||||
private collection = 'shows';
|
||||
private subCollection = 'songs';
|
||||
|
||||
constructor(private dbService: DbService) {
|
||||
}
|
||||
|
||||
public list$ = (showId: string): Observable<ShowSong[]> => this.dbService.col$(`${this.collection}/${showId}/${this.subCollection}`);
|
||||
public read$ = (showId: string, songId: string): Observable<ShowSong | undefined> => this.dbService.doc$(`${this.collection}/${showId}/${this.subCollection}/${songId}`);
|
||||
public update = async (showId: string, songId: string, data: Partial<ShowSong>): Promise<void> => await this.dbService.doc(`${this.collection}/${showId}/${this.subCollection}/${songId}`).update(data);
|
||||
public add = async (showId: string, data: Partial<ShowSong>): Promise<string> => (await this.dbService.col(`${this.collection}/${showId}/${this.subCollection}`).add(data)).id
|
||||
}
|
||||
16
src/app/modules/shows/services/show-song.service.spec.ts
Normal file
16
src/app/modules/shows/services/show-song.service.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
|
||||
import {ShowSongService} from './show-song.service';
|
||||
|
||||
describe('ShowSongService', () => {
|
||||
let service: ShowSongService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ShowSongService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
16
src/app/modules/shows/services/show-song.service.ts
Normal file
16
src/app/modules/shows/services/show-song.service.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ShowSongDataService} from './show-song-data.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ShowSongService {
|
||||
|
||||
constructor(private showSongDataService: ShowSongDataService) {
|
||||
}
|
||||
|
||||
public async new$(showId: string, songId: string): Promise<string> {
|
||||
const data = {songId};
|
||||
return await this.showSongDataService.add(showId, data);
|
||||
}
|
||||
}
|
||||
@@ -10,3 +10,4 @@ export interface Show {
|
||||
public: boolean;
|
||||
reported: boolean;
|
||||
}
|
||||
|
||||
|
||||
4
src/app/modules/shows/services/showSong.ts
Normal file
4
src/app/modules/shows/services/showSong.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export interface ShowSong {
|
||||
id: string;
|
||||
songId: string;
|
||||
}
|
||||
Reference in New Issue
Block a user