📜  firebase 时间戳到日期角度 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:14.302000             🧑  作者: Mango

代码示例1
import { firestore } from 'firebase/app';
import Timestamp = firestore.Timestamp;

@Injectable()
export class YourService {

....

    list = (): Observable => this.collection
        .snapshotChanges()
        .pipe(
            map(changes => {
                return changes.map(a => {
                    const data = a.payload.doc.data() as any;
                    Object.keys(data).filter(key => data[key] instanceof Timestamp)
                        .forEach(key => data[key] = data[key].toDate())
                    data._id = a.payload.doc.id;
                    return data;
                });
            })
        );

...
}