WriteBatch class

A WriteBatch is a series of write operations to be performed as one unit.

Operations done on a WriteBatch do not take effect until you commit().

Once committed, no further operations can be performed on the WriteBatch, nor can it be committed again.

Operations are added to a WriteBatch through a DatabaseReference object that is returned from WriteBatch.reference. The DatabaseReference object behaves similarly to the DatabaseReference instance that is returned from FirebaseDatabase.reference. All writes performed on that reference through the DatabaseReference.set, DatabaseReference.update, and DatabaseReference.remove methods are recorded on the WriteBatch. None of these writes are visible to other clients until WriteBatch.commit is called. They are however immediataley visible to all DatabaseReference and Query objects that are created from WriteBatch.reference.

Note that in some cases, queries might not return the results you expect when used with a WriteBatch. This can happen when you write to a location that was not part of the query result, but should be after the write. Or the other way around. For example, if you query the first 2 children of a location, but the write batch contains a removal of the first child, the query will only return the second child, even when there are actually more than 2 children at that location. This might be fixed in a future version.

Constructors

WriteBatch(DatabaseReference ref)

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

commit() Future<void>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reference() → DatabaseReference
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited