flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[📚] [cloud_firestore_odm] Document how to use transaction in the update method

Open iLoveDocs opened this issue 2 years ago • 0 comments

If I want to use transactionUpdate() method, I need to provide a Transaction object, but there is no documentation on how to create this object. For example, this code doesn't compile:

usersRef 
  .doc('foo_id')
  .transactionUpdate(
    transaction, // How to create this object? 
    name: 'John',
  );

I can create a Transaction object, using

var transaction = FirebaseFirestore.instance.runTransaction((txn) async {
  return txn;  
});

but using this object doesn't work in the first code. Here's the question on StackOverflow.

iLoveDocs avatar Dec 09 '22 21:12 iLoveDocs