Firebase Transactions

There are two movements right here that require anticipate. I need each to occur atomically. If the primary one executes after which the web is going down, I are not looking for the second one to execute, and I need the primary to opposite.

ultimate Reference ref = FirebaseStorage.example.ref().kid(‘product_image’) .kid(newProduct.identification);
anticipate ref.putFile(imageFile).whenComplete(() => null);
anticipate db.assortment(kProductsCollection).

I thought of doing this the use of transactions, however there may be no longer transaction.putFile() means, so I have no idea if this code is gonna paintings the way in which I need it.

anticipate FirebaseFirestore.example.runTransaction((transaction) async {
ultimate Reference ref = FirebaseStorage.example
anticipate ref.putFile(imageFile);
ultimate productRef = db.assortment(kProductsCollection).document(newProduct.identification);
anticipate transaction.set(productRef, newProductWithImageUrl.toJson());

What do you assume?

View Reddit through grossartig_dudeView Supply

You may also like...

WP2Social Auto Publish Powered By :