cofounderella/lib/models/swipe.dart

26 lines
686 B
Dart
Raw Normal View History

2024-06-06 16:11:26 +02:00
import 'package:cloud_firestore/cloud_firestore.dart';
import '../constants.dart';
class Swipe {
final String swiperId;
final String swipedId;
final bool liked;
final DateTime timestamp;
Swipe(
{required this.swiperId,
required this.swipedId,
required this.liked,
required this.timestamp});
factory Swipe.fromDocument(DocumentSnapshot doc) {
var data = doc.data() as Map<String, dynamic>;
return Swipe(
swiperId: doc.id, // Assign document ID
swipedId: data[Constants.dbFieldSwipesSwipedId],
liked: data[Constants.dbFieldSwipesLike] as bool,
timestamp: data[Constants.dbFieldSwipesTimestamp].toDate(),
);
}
}