-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
platform_interface_transaction.dart
67 lines (56 loc) 路 2.6 KB
/
platform_interface_transaction.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// ignore_for_file: require_trailing_commas
// Copyright 2020, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'package:cloud_firestore_platform_interface/cloud_firestore_platform_interface.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
/// The [TransactionHandler] may be executed multiple times, it should be able
/// to handle multiple executions.
typedef TransactionHandler<T extends dynamic> = Future<T?>? Function(
TransactionPlatform);
/// A [TransactionPlatform] is a set of read and write operations on one or more documents.
abstract class TransactionPlatform extends PlatformInterface {
/// Constructor.
TransactionPlatform() : super(token: _token);
static final Object _token = Object();
/// Throws an [AssertionError] if [instance] does not extend
/// [TransactionPlatform].
///
/// This is used by the app-facing [Transaction] to ensure that
/// the object in which it's going to delegate calls has been
/// constructed properly.
static void verify(TransactionPlatform instance) {
PlatformInterface.verify(instance, _token);
}
/// Returns all transaction commands for the current instance.
List<Map<String, dynamic>> get commands {
throw UnimplementedError('commands is not implemented');
}
/// Reads the document referenced by the provided [documentPath].
///
/// If the document changes whilst the transaction is in progress, it will
/// be re-tried up to five times.
Future<DocumentSnapshotPlatform> get(String documentPath) {
throw UnimplementedError('get() is not implemented');
}
/// Deletes the document referred to by the provided [documentPath].
TransactionPlatform delete(String documentPath) {
throw UnimplementedError('delete() is not implemented');
}
/// Updates fields in the document referred to by [documentPath].
/// The update will fail if applied to a document that does not exist.
TransactionPlatform update(
String documentPath,
Map<String, dynamic> data,
) {
throw UnimplementedError('update() is not implemented');
}
/// Writes to the document referred to by the provided [documentPath].
/// If the document does not exist yet, it will be created. If you pass
/// [SetOptions], the provided [data] can be merged into the existing document.
TransactionPlatform set(String documentPath, Map<String, dynamic> data,
[SetOptions? options]) {
throw UnimplementedError('set() is not implemented');
}
}