Skip to content

Commit eac2037

Browse files
Merge
2 parents eb4470a + f06de88 commit eac2037

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/document.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ class DocumentTransform {
13141314
transforms.set(path, val);
13151315
} else {
13161316
throw new Error(
1317-
'Server timestamps are not supported as array values.'
1317+
'FieldValue transformations are not supported inside of array values.'
13181318
);
13191319
}
13201320
} else if (is.array(val)) {

src/field-value.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@
1616

1717
'use strict';
1818

19+
/*!
20+
* Sentinel value for a field delete.
21+
*
22+
*/
23+
let DELETE_SENTINEL;
24+
25+
/*!
26+
* Sentinel value for a server timestamp.
27+
*
28+
*/
29+
let SERVER_TIMESTAMP_SENTINEL;
30+
1931
/**
2032
* Sentinel values that can be used when writing documents with set() or
2133
* update().
@@ -45,7 +57,7 @@ class FieldValue {
4557
* });
4658
*/
4759
static delete() {
48-
return new DeleteTransform();
60+
return DELETE_SENTINEL;
4961
}
5062

5163
/**
@@ -66,7 +78,7 @@ class FieldValue {
6678
* });
6779
*/
6880
static serverTimestamp() {
69-
return new ServerTimestampTransform();
81+
return SERVER_TIMESTAMP_SENTINEL;
7082
}
7183

7284
/**
@@ -117,6 +129,8 @@ class DeleteTransform extends FieldTransform {
117129
}
118130
}
119131

132+
DELETE_SENTINEL = new DeleteTransform();
133+
120134
/**
121135
* A transform that sets a field to the Firestore server time.
122136
*
@@ -157,6 +171,8 @@ class ServerTimestampTransform extends FieldTransform {
157171
}
158172
}
159173

174+
SERVER_TIMESTAMP_SENTINEL = new ServerTimestampTransform();
175+
160176
module.exports = {
161177
FieldValue: FieldValue,
162178
FieldTransform: FieldTransform,

test/document.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ describe('serialize document', function() {
408408
});
409409

410410
it("doesn't support server timestamp in array", function() {
411-
const expectedErr = /Server timestamps are not supported as array values./;
411+
const expectedErr = /FieldValue transformations are not supported inside of array values./;
412412

413413
assert.throws(() => {
414414
return firestore.doc('collectionId/documentId').set({

0 commit comments

Comments
 (0)