Flatter Firebase时间戳搜索查询

Flatter Firebase时间戳搜索查询,firebase,flutter,dart,google-cloud-firestore,Firebase,Flutter,Dart,Google Cloud Firestore,在我的应用中,用户可以发布。像这样在firebase的邮局 我想把上周寄来的所有邮件都拿来。我的搜索查询需要一些过滤器。但我不知道我该怎么做。 这是我的搜索查询 _newQuerySnapshot = await Firestore.instance .collection("posts") .orderBy("createdAt", descending: true) .startAfterDocument(lastDocument) .lim

在我的应用中,用户可以发布。像这样在firebase的邮局

我想把上周寄来的所有邮件都拿来。我的搜索查询需要一些过滤器。但我不知道我该怎么做。 这是我的搜索查询

_newQuerySnapshot = await Firestore.instance
      .collection("posts")
      .orderBy("createdAt", descending: true)
      .startAfterDocument(lastDocument)
      .limit(5)
      .getDocuments();
我需要这样的。上周发到哪里了 请帮帮我。

你可以在firestore中使用where查询,

你可以在firestore中使用where查询,

我这样解决了

 var beginningDate = DateTime.now();
        var newDate=beginningDate.subtract(Duration(days: 1));



          _newQuerySnapshot = await Firestore.instance
              .collection("posts").where("createdAt",isGreaterThanOrEqualTo: newDate)
              .orderBy("createdAt", descending: true)
              .limit(5)
              .getDocuments();
我是这样解决的

 var beginningDate = DateTime.now();
        var newDate=beginningDate.subtract(Duration(days: 1));



          _newQuerySnapshot = await Firestore.instance
              .collection("posts").where("createdAt",isGreaterThanOrEqualTo: newDate)
              .orderBy("createdAt", descending: true)
              .limit(5)
              .getDocuments();

或者你可以这样做

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)
            });

或者你可以这样做

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)
            });

:D好的,但是怎么做?:D好的,但是怎么做?