gpt4 book ai didi

firebase - Flutter Firebase 时间戳

转载 作者:行者123 更新时间:2023-12-03 03:22:16 26 4
gpt4 key购买 nike

我想显示今天或上周创建的帖子。我怎样才能做到这一点。

这是我的 Firebase 数据 enter image description here

这是我的问题

  Future<List<Post>> getAllPost(Post lastFetched, int fetchLimit) async {
List<Post> _postList = [];
if (lastFetched == null) {
_querySnapshot = await Firestore.instance
.collection("posts")
.orderBy("liked", descending: true)
.limit(fetchLimit)
.getDocuments();
} else {
_querySnapshot = await Firestore.instance
.collection("posts")
.orderBy("liked", descending: true)
.startAfterDocument(lastDocument)
.limit(fetchLimit)
.getDocuments();
}
if (_querySnapshot.documents.length != 0) {
lastDocument =
_querySnapshot.documents[_querySnapshot.documents.length - 1];
}

for (DocumentSnapshot documentSnapshot in _querySnapshot.documents) {
Post tekPost = Post.fromMap(documentSnapshot.data);
_postList.add(tekPost);
}
return _postList;
}

最佳答案

var startfulldate = admin.firestore.Timestamp.fromDate(new Date(1556062581000));
db.collection('mycollection')
.where('start_time', '<=', startfulldate)
.get()
.then(snapshot => {
var jsonvalue: any[] = [];
snapshot.forEach(docs => {
jsonvalue.push(docs.data())
})
res.send(jsonvalue);
return;
}).catch( error => {
res.status(500).send(error)
});

关于firebase - Flutter Firebase 时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61915288/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com