类型“ DocumentChange”上不存在属性“ entryDate”

时间:2020-04-24 05:59:23

标签: firebase google-cloud-firestore

我正在使用.snapshotChanges()从Firestore提取数据。它有一个名为entryDate的时间戳字段。导入数据时,我试图更改其格式。为此,我必须将timestamp分配给变量,但会出错。下面是我的代码:

错误在这里:const timeinmillsecs = item.payload.entryDate.seconds * 1000; // error on this line

 this.firestore.collection('projects' , ref => ref
    .limit(10) 
    .orderBy('entryDate', 'desc')
    )
    .snapshotChanges()
    .subscribe(response => {
    if(!response.length){
      console.log("no data available");
      return false; 
    }
    this.firstInResponse = response[0].payload.doc;
    this.lastInResponse = response[response.length - 1].payload.doc;
    console.log(this.firstInResponse);
    console.log(this.lastInResponse);
    this.tableData=[];  
    for(let item of response){
     const timeinmillsecs = item.payload.entryDate.seconds * 1000;  // error on this line
     ...

错误截图:

enter image description here

0 个答案:

没有答案