@google-cloud/firestore
Advanced tools
Comparing version 4.6.0 to 4.6.1
@@ -61,2 +61,4 @@ "use strict"; | ||
this.state = BatchState.OPEN; | ||
// The set of document reference paths present in the WriteBatch. | ||
this.docPaths = new Set(); | ||
// An array of pending write operations. Only contains writes that have not | ||
@@ -79,3 +81,3 @@ // been resolved. | ||
this.writeBatch.create(documentRef, data); | ||
return this.processLastOperation(); | ||
return this.processLastOperation(documentRef); | ||
} | ||
@@ -88,3 +90,3 @@ /** | ||
this.writeBatch.delete(documentRef, precondition); | ||
return this.processLastOperation(); | ||
return this.processLastOperation(documentRef); | ||
} | ||
@@ -97,3 +99,3 @@ /** | ||
this.writeBatch.set(documentRef, data, options); | ||
return this.processLastOperation(); | ||
return this.processLastOperation(documentRef); | ||
} | ||
@@ -106,3 +108,3 @@ /** | ||
this.writeBatch.update(documentRef, dataOrField, ...preconditionOrValues); | ||
return this.processLastOperation(); | ||
return this.processLastOperation(documentRef); | ||
} | ||
@@ -113,3 +115,5 @@ /** | ||
*/ | ||
processLastOperation() { | ||
processLastOperation(documentRef) { | ||
assert(!this.docPaths.has(documentRef.path), 'Batch should not contain writes to the same document'); | ||
this.docPaths.add(documentRef.path); | ||
assert(this.state === BatchState.OPEN, 'Batch should be OPEN when adding writes'); | ||
@@ -590,6 +594,7 @@ const deferred = new util_1.Deferred(); | ||
*/ | ||
getEligibleBatch(batchQueue) { | ||
getEligibleBatch(documentRef, batchQueue) { | ||
if (batchQueue.length > 0) { | ||
const lastBatch = batchQueue[batchQueue.length - 1]; | ||
if (lastBatch.state === BatchState.OPEN) { | ||
if (lastBatch.state === BatchState.OPEN && | ||
!lastBatch.docPaths.has(documentRef.path)) { | ||
return lastBatch; | ||
@@ -684,3 +689,3 @@ } | ||
const batchQueue = failedAttempts > 0 ? this._retryBatchQueue : this._batchQueue; | ||
const bulkCommitBatch = this.getEligibleBatch(batchQueue); | ||
const bulkCommitBatch = this.getEligibleBatch(documentRef, batchQueue); | ||
// Send ready batches if this is the first attempt. Subsequent retry | ||
@@ -687,0 +692,0 @@ // batches are scheduled after the initial batch returns. |
@@ -7,2 +7,9 @@ # Changelog | ||
### [4.6.1](https://www.github.com/googleapis/nodejs-firestore/compare/v4.6.0...v4.6.1) (2020-11-03) | ||
### Bug Fixes | ||
* create new batch for writes to the same doc ([#1352](https://www.github.com/googleapis/nodejs-firestore/issues/1352)) ([bd5adc3](https://www.github.com/googleapis/nodejs-firestore/commit/bd5adc35ea1f662ee762ac8b9048556e78a54f35)) | ||
## [4.6.0](https://www.github.com/googleapis/nodejs-firestore/compare/v4.5.0...v4.6.0) (2020-11-03) | ||
@@ -9,0 +16,0 @@ |
{ | ||
"name": "@google-cloud/firestore", | ||
"description": "Firestore Client Library for Node.js", | ||
"version": "4.6.0", | ||
"version": "4.6.1", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "author": "Google Inc.", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4457788
83006