parent
271cefff0c
commit
44b6477101
@ -1,15 +1,19 @@
|
|||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
import '../Post.dart';
|
import '../Post.dart';
|
||||||
|
|
||||||
class PostMapper {
|
class PostMapper {
|
||||||
static Map<String, dynamic> toFirebase(Post post) {
|
static Post toModel(DocumentSnapshot<Map<String, dynamic>> snapshot) {
|
||||||
return {
|
final data = snapshot.data();
|
||||||
"user_id": post.idUser,
|
return Post(
|
||||||
"description": post.description ?? "",
|
snapshot.id,
|
||||||
"date": post.date,
|
data?["user_id"],
|
||||||
"place": post.location ?? "",
|
data?["description"],
|
||||||
"selfie": post.selfie ?? "",
|
data?["song_id"],
|
||||||
"song_id": post.idMusic,
|
Tuple2(data?["place"][0], data?["place"][1]),
|
||||||
"likes": post.nblikes
|
data?["likes"],
|
||||||
};
|
data?["selfie"],
|
||||||
|
data?["date"].toDate());
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in new issue