File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
packages/firestore/src/core Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -142,12 +142,18 @@ export class Transaction {
142
142
143
143
/**
144
144
* Returns the version of this document when it was read in this transaction,
145
- * as a precondition, or no precondition if it was not read.
145
+ * as a precondition, or an existence precondition if the document did not
146
+ * exist, or no precondition if it was not read.
146
147
*/
147
148
private precondition ( key : DocumentKey ) : Precondition {
148
149
const version = this . readVersions . get ( key . toString ( ) ) ;
149
150
if ( ! this . writtenDocs . has ( key . toString ( ) ) && version ) {
150
- return Precondition . updateTime ( version ) ;
151
+ if ( version . isEqual ( SnapshotVersion . min ( ) ) ) {
152
+ // The document doesn't exist.
153
+ return Precondition . exists ( false ) ;
154
+ } else {
155
+ return Precondition . updateTime ( version ) ;
156
+ }
151
157
} else {
152
158
return Precondition . none ( ) ;
153
159
}
You can’t perform that action at this time.
0 commit comments