File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,21 @@ export function objectToValueProto(data: object) {
161
161
bytesValue : val ,
162
162
} ;
163
163
}
164
+ if ( val instanceof firestore . DocumentReference ) {
165
+ const projectId : string = get ( val , '_referencePath.projectId' ) ;
166
+ const database : string = get ( val , '_referencePath.databaseId' ) ;
167
+ const referenceValue : string = [
168
+ 'projects' , projectId ,
169
+ 'databases' , database ,
170
+ val . path ,
171
+ ] . join ( '/' ) ;
172
+ return { referenceValue } ;
173
+ }
174
+ if ( val instanceof firestore . Timestamp ) {
175
+ return {
176
+ timestampValue : val . toDate ( ) . toISOString ( ) ,
177
+ } ;
178
+ }
164
179
if ( isPlainObject ( val ) ) {
165
180
return {
166
181
mapValue : {
@@ -170,7 +185,7 @@ export function objectToValueProto(data: object) {
170
185
}
171
186
throw new Error (
172
187
'Cannot encode ' + val + 'to a Firestore Value.' +
173
- ' Local testing does not yet support Firestore document reference values or geo points.' ) ;
188
+ ' Local testing does not yet support Firestore geo points.' ) ;
174
189
} ;
175
190
176
191
return mapValues ( data , encodeHelper ) ;
You can’t perform that action at this time.
0 commit comments