PPS*_*PPS 3 timestamp node.js firebase angular google-cloud-firestore
我有票务发布 Web 应用程序,我将只显示那些有效且在 24 小时内记录的票(从现在开始)。
我正在将Firebase Cloud Firestore与Angular 7 一起使用。
getTicketList(){
this.ticketData =
this.fireStore.collection('ticket').doc("paid").collection("ticket-list",
ref =>
ref.where('status', '==',
"active").where("paid","==","false").orderBy("myTimeStamp");
return this.ticketData.snapshotChanges() ;
}
Run Code Online (Sandbox Code Playgroud)
我们有一个键“myTimestamp”,它是Firestore 时间戳类型。
只想显示那些处于活动状态且当前还有剩余时间可以预订的记录。
下面我提到了我用来从 Firebase 服务获取的代码。
this.firestore.getTicketList().subscribe(list => {
this.ticketList = list.map(item => {
return { id:item.payload.doc.id,
...item.payload.doc.data()}
})
console.log(this.ticketList);
});
Run Code Online (Sandbox Code Playgroud)
谢谢
已编辑
您可以通过传递Date对象来查询数据/时间戳字段。例如,现在获取所有项目:
ref
.where('status', '==', "active")
.where("paid","==","false")
.where("myTimeStamp","<", new Date())
.orderBy("myTimeStamp")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6317 次 |
| 最近记录: |