firebase - Flutter Firebase 时间戳

标签 firebase flutter dart google-cloud-firestore

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

这是我的 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/

相关文章:

flutter - 如何在flutter中设置布局元素的背景颜色

android - Flutter audioplayers : How to handle PlatformException(AndroidAudioError, 标有@UiThread的方法必须在主线程执行)

formatting - Dart 中的货币格式

firebase - 在 Firebase 中创建逻辑

javascript - Firestore 特定数据读取不适用于变量,但适用于静态值

firebase - 如何通过 cli 输出 Firestore 配置

ios - RxSwift 回调在结果之前先返回

flutter - 如何防止在父小部件 GestureDetector 上触发 onTapDown?

webview - 如何使用 flutter webview 获取 html 元数据

java - 如何从 Swift 原生代码到 Flutter 的 'put' 参数