[英]How to assign Class to data retrieved from Firestore in Firebase functions(typescript)?
I'm retriving data from firestore and at the same times I'm trying to assign class to data that is recived but that does not work, what is the correct way of doing that? 我正在从Firestore检索数据,同时尝试将类分配给已接收但无法正常工作的数据,这样做的正确方法是什么?
async function getAcceptedShifts(monthKey: string):Promise<Shift[]> {
return (await db.collection('companies').doc(companyIdd)
.collection('months')
.doc(monthKey).collection('acceptedShifts')
.get()).docs.map(val=>{
let s = val.data as Shift
return s;
})
}
and the Shift class: 和Shift类:
class Shift{
changeDate?: Date;
startTime?: { year: number, month: number
, day: number, hour: number, minute: number };
endTime?: { year: number, month: number
, day: number, hour: number, minute: number };
employeeId?:string
}
well the correct way is: 正确的方法是:
return val.data()
-so the problem was missing paranteses! -所以问题是缺少父母! -.-
-.-
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.