blob: 18573b604f9760f3bcbe39337cb6336102104d2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import 'package:cloud_firestore/cloud_firestore.dart';
class FavoritesFirebase {
final FirebaseFirestore _firestore = FirebaseFirestore.instance;
late CollectionReference _collection;
FavoritesFirebase() {
_collection = _firestore.collection('popular_favorites');
}
Future<void> insertFavorite(Map<String, dynamic> map) async {
await _collection.doc().set(map);
}
Future<void> updateFavorite(Map<String, dynamic> map, String id) async {
await _collection.doc(id).update(map);
}
Future<void> deleteFavorite(String id) async {
await _collection.doc(id).delete();
}
Stream<QuerySnapshot> getAllFavorites() {
return _collection.snapshots();
}
}
|