firebase timestamp to date angular

Solutions on MaxInterview for firebase timestamp to date angular by the best coders in the world

showing results for - "firebase timestamp to date angular"
Federico
20 Jan 2017
1import { firestore } from 'firebase/app';
2import Timestamp = firestore.Timestamp;
3
4@Injectable()
5export class YourService {
6
7....
8
9    list = (): Observable<any[]> => this.collection
10        .snapshotChanges()
11        .pipe(
12            map(changes => {
13                return changes.map(a => {
14                    const data = a.payload.doc.data() as any;
15                    Object.keys(data).filter(key => data[key] instanceof Timestamp)
16                        .forEach(key => data[key] = data[key].toDate())
17                    data._id = a.payload.doc.id;
18                    return data;
19                });
20            })
21        );
22
23...
24}
25