migrate firebase db
This commit is contained in:
@@ -3,8 +3,7 @@ import {Observable} from 'rxjs';
|
||||
import {DbService} from '../../../services/db.service';
|
||||
import {Show} from './show';
|
||||
import {map, shareReplay} from 'rxjs/operators';
|
||||
import {QueryFn} from '@angular/fire/compat/firestore/interfaces';
|
||||
import firebase from 'firebase/compat/app';
|
||||
import {orderBy, QueryConstraint, Timestamp, where} from '@angular/fire/firestore';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -28,11 +27,11 @@ export class ShowDataService {
|
||||
const startDate = new Date();
|
||||
startDate.setHours(0, 0, 0, 0);
|
||||
startDate.setDate(startDate.getDate() - lastMonths * 30);
|
||||
const startTimestamp = firebase.firestore.Timestamp.fromDate(startDate);
|
||||
const startTimestamp = Timestamp.fromDate(startDate);
|
||||
|
||||
const queryFn: QueryFn = ref => ref.where('published', '==', true).where('date', '>=', startTimestamp).orderBy('date', 'desc');
|
||||
const queryConstraints: QueryConstraint[] = [where('published', '==', true), where('date', '>=', startTimestamp), orderBy('date', 'desc')];
|
||||
|
||||
return this.dbService.col$<Show>(this.collection, queryFn).pipe(
|
||||
return this.dbService.col$<Show>(this.collection, queryConstraints).pipe(
|
||||
map(shows => shows.filter(show => !show.archived)),
|
||||
shareReplay({
|
||||
bufferSize: 1,
|
||||
|
||||
@@ -2,7 +2,7 @@ import {Injectable} from '@angular/core';
|
||||
import {DbService} from '../../../services/db.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {ShowSong} from './show-song';
|
||||
import {QueryFn} from '@angular/fire/compat/firestore/interfaces';
|
||||
import {QueryConstraint} from '@angular/fire/firestore';
|
||||
import {shareReplay} from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
@@ -15,9 +15,9 @@ export class ShowSongDataService {
|
||||
|
||||
public constructor(private dbService: DbService) {}
|
||||
|
||||
public list$ = (showId: string, queryFn?: QueryFn): Observable<ShowSong[]> => {
|
||||
if (queryFn) {
|
||||
return this.dbService.col$(`${this.collection}/${showId}/${this.subCollection}`, queryFn);
|
||||
public list$ = (showId: string, queryConstraints?: QueryConstraint[]): Observable<ShowSong[]> => {
|
||||
if (queryConstraints && queryConstraints.length > 0) {
|
||||
return this.dbService.col$(`${this.collection}/${showId}/${this.subCollection}`, queryConstraints);
|
||||
}
|
||||
|
||||
const cached = this.listCache.get(showId);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import firebase from 'firebase/compat/app';
|
||||
import Timestamp = firebase.firestore.Timestamp;
|
||||
import {Timestamp} from '@angular/fire/firestore';
|
||||
|
||||
export type PresentationBackground = 'none' | 'blue' | 'green' | 'leder' | 'praise' | 'bible';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user