@@ -52,9 +52,9 @@ function _getValueProto(data: any, resource: string, valueFieldName: string) {
5252}
5353
5454/** @internal */
55- export function createSnapshotFromProtobuf ( data : Uint8Array , path : string ) {
55+ export function createSnapshotFromProtobuf ( data : Uint8Array , path : string , databaseId : string ) {
5656 if ( ! firestoreInstance ) {
57- firestoreInstance = firestore . getFirestore ( getApp ( ) ) ;
57+ firestoreInstance = firestore . getFirestore ( databaseId ) ;
5858 }
5959 try {
6060 const dataBuffer = Buffer . from ( data ) ;
@@ -68,9 +68,13 @@ export function createSnapshotFromProtobuf(data: Uint8Array, path: string) {
6868}
6969
7070/** @internal */
71- export function createBeforeSnapshotFromProtobuf ( data : Uint8Array , path : string ) {
71+ export function createBeforeSnapshotFromProtobuf (
72+ data : Uint8Array ,
73+ path : string ,
74+ databaseId : string
75+ ) {
7276 if ( ! firestoreInstance ) {
73- firestoreInstance = firestore . getFirestore ( getApp ( ) ) ;
77+ firestoreInstance = firestore . getFirestore ( databaseId ) ;
7478 }
7579 try {
7680 const dataBuffer = Buffer . from ( data ) ;
@@ -88,10 +92,13 @@ export function createSnapshotFromJson(
8892 data : any ,
8993 source : string ,
9094 createTime : string | undefined ,
91- updateTime : string | undefined
95+ updateTime : string | undefined ,
96+ databaseId ?: string
9297) {
9398 if ( ! firestoreInstance ) {
94- firestoreInstance = firestore . getFirestore ( getApp ( ) ) ;
99+ firestoreInstance = databaseId
100+ ? firestore . getFirestore ( databaseId )
101+ : firestore . getFirestore ( getApp ( ) ) ;
95102 }
96103 const valueProto = _getValueProto ( data , source , "value" ) ;
97104 let timeString = createTime || updateTime ;
@@ -110,11 +117,15 @@ export function createBeforeSnapshotFromJson(
110117 data : any ,
111118 source : string ,
112119 createTime : string | undefined ,
113- updateTime : string | undefined
120+ updateTime : string | undefined ,
121+ databaseId ?: string
114122) {
115123 if ( ! firestoreInstance ) {
116- firestoreInstance = firestore . getFirestore ( getApp ( ) ) ;
124+ firestoreInstance = databaseId
125+ ? firestore . getFirestore ( databaseId )
126+ : firestore . getFirestore ( getApp ( ) ) ;
117127 }
128+
118129 const oldValueProto = _getValueProto ( data , source , "oldValue" ) ;
119130 const oldReadTime = dateToTimestampProto ( createTime || updateTime ) ;
120131 return firestoreInstance . snapshot_ ( oldValueProto , oldReadTime , "json" ) ;
0 commit comments