mirror of https://github.com/flutter/samples.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
670 B
26 lines
670 B
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
|
|
import '../features/recipes/recipe_model.dart';
|
|
|
|
const recipePath = '/recipes';
|
|
final firestore = FirebaseFirestore.instance;
|
|
|
|
class FirestoreService {
|
|
static Future<Null> saveRecipe(Recipe recipe) async {
|
|
await firestore
|
|
.collection(recipePath)
|
|
.doc(recipe.id)
|
|
.set(recipe.toFirestore());
|
|
}
|
|
|
|
static Future<Null> deleteRecipe(Recipe recipe) async {
|
|
await firestore.doc("$recipePath/${recipe.id}").delete();
|
|
}
|
|
|
|
static Future<Null> updateRecipe(Recipe recipe) async {
|
|
await firestore
|
|
.doc("$recipePath/${recipe.id}")
|
|
.update(recipe.toFirestore());
|
|
}
|
|
}
|