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) {
161161 bytesValue : val ,
162162 } ;
163163 }
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+ }
164179 if ( isPlainObject ( val ) ) {
165180 return {
166181 mapValue : {
@@ -170,7 +185,7 @@ export function objectToValueProto(data: object) {
170185 }
171186 throw new Error (
172187 '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.' ) ;
174189 } ;
175190
176191 return mapValues ( data , encodeHelper ) ;
You can’t perform that action at this time.
0 commit comments