parent
1b132c3e58
commit
8ef2bba431
@ -0,0 +1,15 @@
|
|||||||
|
import '../Post.dart';
|
||||||
|
|
||||||
|
class PostMapper {
|
||||||
|
static Map<String, dynamic> toFirebase(Post post) {
|
||||||
|
return {
|
||||||
|
"user_id": post.idUser,
|
||||||
|
"description": post.description ?? "",
|
||||||
|
"date": post.date,
|
||||||
|
"place": post.location ?? "",
|
||||||
|
"selfie": post.selfie ?? "",
|
||||||
|
"song_id": post.idMusic,
|
||||||
|
"likes": post.nblikes
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
import '../main.dart';
|
||||||
|
import '../model/Post.dart';
|
||||||
|
import '../model/mapper/PostMapper.dart';
|
||||||
|
|
||||||
|
class PostService {
|
||||||
|
createPost(Post post) {
|
||||||
|
MyApp.db
|
||||||
|
.collection("posts")
|
||||||
|
.add(PostMapper.toFirebase(post))
|
||||||
|
.then((value) => print("Post Added"))
|
||||||
|
.catchError((error) => print("Failed to add post: $error"));
|
||||||
|
}
|
||||||
|
|
||||||
|
deletePost() {}
|
||||||
|
|
||||||
|
getPostsById(String id) {}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
const geoKey = "85a2724ad38b3994c2b7ebe1d239bbff";
|
Loading…
Reference in new issue