DocumentReference class
Holds a reference to a document. A document reference is a reference to a specific record in a collection. You can use it to read or write data to the document. A document can refer to a row in a table in a relational database or a document in a NoSQL database. Additionally, a document reference can refer to a non-existent document, which you can use to create a new document.
Read more about document references in the documentation.
Constructors
- DocumentReference.new(SquidDocId _squidDocId, DataManager _dataManager, QueryBuilderFactory _queryBuilderFactory)
Properties
- data → DocumentData
-
Returns the document data. Throws an error if the document doesn't exist.
no setter
- hasData → bool
-
Returns whether data has been populated for this document reference.
Data will not present if a document has not been queried, does not exist,
or has been deleted.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- refId → String
-
A string that uniquely identifies this document reference.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
decrementInPath(
String path, num value, [TransactionId? transactionId]) → Future< void> -
Decrements the value at the given
path
by the givenvalue
. The givenvalue
may be both positive and negative. -
delete(
[TransactionId? transactionId]) → Future< void> -
Deletes the document.
The delete will be reflected optimistically locally and will be applied
to the server later. If a
transactionId
is provided, the delete will be applied to the server as an atomic operation together with the rest of the operations in the transaction and the delete will not reflect locally until the transaction is completed locally. -
deleteInPath(
String path, [TransactionId? transactionId]) → Future< void> -
Similar to update but only deletes the given
path
. -
incrementInPath(
String path, num value, [TransactionId? transactionId]) → Future< void> -
Increments the value at the given
path
by the givenvalue
. The givenvalue
may be both positive and negative. -
insert(
DocumentData data, [TransactionId? transactionId]) → Future< void> -
Inserts the document with the given
data
. If the document already exists, the operation will be treated asupsert
. The insert will be reflected optimistically locally and will be applied to the server later. If a transactionId is provided, theinsert
will be applied to the server as an atomic operation together with the rest of the operations in the transaction and theinsert
will not reflect locally until the transaction is completed locally. -
isDirty(
) → bool - Returns whether the locally available version of the document may not be the latest version on the server.
-
migrateDocIds(
IdResolutionMap idResolutionMap) → void -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
peek(
) → DocumentData? - Returns the data that is currently available on the client or null if data has not yet been populated.
-
setInPath(
String path, dynamic value, [TransactionId? transactionId]) → Future< void> -
Similar to update but only updates the given
path
. -
snapshot(
) → Future< DocumentReference?> - Returns a DocumentReference with the latest data from the server or null if the document does not exist on the server.
-
snapshots(
) → Observable< DocumentData?> - Returns a stream that emits a DocumentReference with the latest data from the server or null if the document is deleted or does not exist on the server.
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
DocumentData data, [TransactionId? transactionId]) → Future< void> -
Updates the document with the given
data
. The update will be reflected optimistically locally and will be applied to the server later. If a transactionId is provided, the update will be applied to the server as an atomic operation together with the rest of the operations in the transaction and the update will not reflect locally until the transaction is completed locally.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited