Skip to content

batchSet and transactionSet should rely on castedReference like set #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions packages/cloud_firestore_odm/example/lib/integration.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions packages/cloud_firestore_odm/example/lib/integration/enums.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 60 additions & 10 deletions packages/cloud_firestore_odm/example/lib/integration/query.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 24 additions & 4 deletions packages/cloud_firestore_odm/example/lib/movie.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions packages/cloud_firestore_odm/example/lib/movie_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,16 @@ class _LikesState extends State<Likes> {
// count on the server.
final newLikes = await FirebaseFirestore.instance
.runTransaction<int>((transaction) async {
final movie = await transaction.get<Movie>(widget.reference.reference);
final movie = await widget.reference.transactionGet(transaction);

if (!movie.exists) {
throw Exception('Document does not exist!');
}

final updatedLikes = movie.data()!.likes + 1;
transaction.update(
widget.reference.reference,
<String, Object?>{'likes': updatedLikes},
final updatedLikes = movie.data!.likes + 1;
widget.reference.transactionUpdate(
transaction,
likes: updatedLikes,
);
return updatedLikes;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class _FilmListState extends State<FilmList> {
final batch = FirebaseFirestore.instance.batch();

for (final movie in movies.docs) {
batch.update(movie.reference.reference, <String, Object?>{'likes': 0});
movie.reference.batchUpdate(batch, likes: 0);
}
await batch.commit();
}
Expand Down
Loading