26 lines
686 B
Dart
26 lines
686 B
Dart
|
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(),
|
||
|
);
|
||
|
}
|
||
|
}
|