everyone. In the query below how can I get only the data for the current month?
my firestore DB:
my code:
@override
Stream<List<TodoModel>> getTodos() {
return firestore.collection('todo')
.orderBy('myDate', descending: true)
.snapshots()
.map((query) {
return query.documents.map((doc) {
return TodoModel.fromDocument(doc);
}).toList();
});
}
Any idea how I can do that? Thanks
Can you try this
Stream<List<TodoModel>> getTodos() {
var date = DateTime.now();
return Firestore.instance.collection('todo')
.where('myDate', isGreaterThanOrEqualTo: new DateTime(date.year, date.month, 1))
.orderBy('myDate', descending: true)
.snapshots()
.map((query) {
return query.documents.map((doc) {
return TodoModel.fromDocument(doc);
}).toList();
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.