File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -1314,7 +1314,7 @@ class DocumentTransform {
1314
1314
transforms . set ( path , val ) ;
1315
1315
} else {
1316
1316
throw new Error (
1317
- 'Server timestamps are not supported as array values.'
1317
+ 'FieldValue transformations are not supported inside of array values.'
1318
1318
) ;
1319
1319
}
1320
1320
} else if ( is . array ( val ) ) {
Original file line number Diff line number Diff line change 16
16
17
17
'use strict' ;
18
18
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
+
19
31
/**
20
32
* Sentinel values that can be used when writing documents with set() or
21
33
* update().
@@ -45,7 +57,7 @@ class FieldValue {
45
57
* });
46
58
*/
47
59
static delete ( ) {
48
- return new DeleteTransform ( ) ;
60
+ return DELETE_SENTINEL ;
49
61
}
50
62
51
63
/**
@@ -66,7 +78,7 @@ class FieldValue {
66
78
* });
67
79
*/
68
80
static serverTimestamp ( ) {
69
- return new ServerTimestampTransform ( ) ;
81
+ return SERVER_TIMESTAMP_SENTINEL ;
70
82
}
71
83
72
84
/**
@@ -117,6 +129,8 @@ class DeleteTransform extends FieldTransform {
117
129
}
118
130
}
119
131
132
+ DELETE_SENTINEL = new DeleteTransform ( ) ;
133
+
120
134
/**
121
135
* A transform that sets a field to the Firestore server time.
122
136
*
@@ -157,6 +171,8 @@ class ServerTimestampTransform extends FieldTransform {
157
171
}
158
172
}
159
173
174
+ SERVER_TIMESTAMP_SENTINEL = new ServerTimestampTransform ( ) ;
175
+
160
176
module . exports = {
161
177
FieldValue : FieldValue ,
162
178
FieldTransform : FieldTransform ,
Original file line number Diff line number Diff line change @@ -408,7 +408,7 @@ describe('serialize document', function() {
408
408
} ) ;
409
409
410
410
it ( "doesn't support server timestamp in array" , function ( ) {
411
- const expectedErr = / S e r v e r t i m e s t a m p s a r e n o t s u p p o r t e d a s a r r a y v a l u e s ./ ;
411
+ const expectedErr = / F i e l d V a l u e t r a n s f o r m a t i o n s a r e n o t s u p p o r t e d i n s i d e o f a r r a y v a l u e s ./ ;
412
412
413
413
assert . throws ( ( ) => {
414
414
return firestore . doc ( 'collectionId/documentId' ) . set ( {
You can’t perform that action at this time.
0 commit comments