initStream method
dynamic
initStream({
- required String collectionId,
- required Map<
String, dynamic> where, - required String orderBy,
- bool descending = true,
- int? limit,
- bool hasPage = false,
override
Implementation
@override
dynamic initStream({
required String collectionId,
required Map<String, dynamic> where,
required String orderBy,
bool descending = true,
int? limit, // 페이지 크기
bool hasPage = false,
}) {
if (_db == null) {
return const Text('database is not initialized');
}
CollectionReference? collectionRef = _db!.collection(collectionId);
Query<Object?> query = collectionRef.orderBy(orderBy, descending: descending);
where.forEach((mid, value) {
query = query.where(mid, isEqualTo: value.value);
});
// 마지막 문서가 있으면, 해당 문서 이후부터 데이터 로드
if (limit != null) {
query = query.limit(limit);
}
if (startAfter != null && hasPage) {
query = query.startAfterDocument(startAfter!);
}
return query.snapshots();
}