Skip to content

Commit b6abc27

Browse files
Test after master merge
1 parent fc11280 commit b6abc27

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

packages/firestore/exp/src/api/snapshot.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ export class DocumentSnapshot<T = firestore.DocumentData>
8383
/* timestampsInSnapshots= */ true,
8484
options.serverTimestamps || DEFAULT_SERVER_TIMESTAMP_BEHAVIOR,
8585
key =>
86-
new DocumentReference(this._firestore, key, /* converter= */ null)
86+
new DocumentReference(
87+
this._firestore,
88+
key.path,
89+
/* converter= */ null
90+
)
8791
);
8892
return userDataWriter.convertValue(this._document.toProto()) as T;
8993
}
@@ -102,7 +106,8 @@ export class DocumentSnapshot<T = firestore.DocumentData>
102106
this._firestoreImpl._databaseId,
103107
/* timestampsInSnapshots= */ true,
104108
options.serverTimestamps || DEFAULT_SERVER_TIMESTAMP_BEHAVIOR,
105-
key => new DocumentReference(this._firestore, key, this._converter)
109+
key =>
110+
new DocumentReference(this._firestore, key.path, this._converter)
106111
);
107112
return userDataWriter.convertValue(value);
108113
}

packages/firestore/lite/src/api/reference.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,24 @@ export class DocumentReference<T = firestore.DocumentData>
7878

7979
constructor(
8080
readonly firestore: Firestore,
81-
key: DocumentKey,
81+
readonly _path: ResourcePath,
8282
readonly _converter: firestore.FirestoreDataConverter<T> | null
8383
) {
84-
super(firestore._databaseId, key, _converter);
84+
super(firestore._databaseId, new DocumentKey(_path), _converter);
8585
}
8686

8787
get id(): string {
88-
return this._key.path.lastSegment();
88+
return this._path.lastSegment();
8989
}
9090

9191
get path(): string {
92-
return this._key.path.canonicalString();
92+
return this._path.canonicalString();
9393
}
9494

9595
withConverter<U>(
9696
converter: firestore.FirestoreDataConverter<U>
9797
): firestore.DocumentReference<U> {
98-
return new DocumentReference<U>(this.firestore, this._key, converter);
98+
return new DocumentReference<U>(this.firestore, this._path, converter);
9999
}
100100
}
101101

@@ -320,8 +320,8 @@ export function collection(
320320
'a DocumentReference or FirebaseFirestore'
321321
);
322322
}
323-
const absolutePath = ResourcePath.fromString(
324-
`${parent.path}/${relativePath}`
323+
const absolutePath = ResourcePath.fromString(parent.path).child(
324+
ResourcePath.fromString(relativePath)
325325
);
326326
validateCollectionPath(absolutePath);
327327
return new CollectionReference(
@@ -385,11 +385,7 @@ export function doc<T>(
385385
if (parent instanceof Firestore) {
386386
const absolutePath = ResourcePath.fromString(relativePath!);
387387
validateDocumentPath(absolutePath);
388-
return new DocumentReference(
389-
parent,
390-
new DocumentKey(absolutePath),
391-
/* converter= */ null
392-
);
388+
return new DocumentReference(parent, absolutePath, /* converter= */ null);
393389
} else {
394390
if (
395391
!(parent instanceof DocumentReference) &&
@@ -401,13 +397,13 @@ export function doc<T>(
401397
'a DocumentReference or FirebaseFirestore'
402398
);
403399
}
404-
const absolutePath = ResourcePath.fromString(
405-
`${parent.path}/${relativePath}`
400+
const absolutePath = parent._path.child(
401+
ResourcePath.fromString(relativePath!)
406402
);
407403
validateDocumentPath(absolutePath);
408404
return new DocumentReference(
409405
parent.firestore,
410-
new DocumentKey(absolutePath),
406+
absolutePath,
411407
parent instanceof CollectionReference ? parent._converter : null
412408
);
413409
}
@@ -429,7 +425,7 @@ export function parent<T>(
429425
} else {
430426
return new DocumentReference(
431427
child.firestore,
432-
new DocumentKey(parentPath),
428+
parentPath,
433429
/* converter= */ null
434430
);
435431
}

packages/firestore/lite/src/api/snapshot.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class DocumentSnapshot<T = firestore.DocumentData>
5252
get ref(): firestore.DocumentReference<T> {
5353
return new DocumentReference<T>(
5454
this._firestore,
55-
this._key,
55+
this._key.path,
5656
this._converter
5757
);
5858
}
@@ -80,7 +80,11 @@ export class DocumentSnapshot<T = firestore.DocumentData>
8080
/* timestampsInSnapshots= */ true,
8181
/* serverTimestampBehavior=*/ 'none',
8282
key =>
83-
new DocumentReference(this._firestore, key, /* converter= */ null)
83+
new DocumentReference(
84+
this._firestore,
85+
key.path,
86+
/* converter= */ null
87+
)
8488
);
8589
return userDataWriter.convertValue(this._document.toProto()) as T;
8690
}
@@ -96,7 +100,8 @@ export class DocumentSnapshot<T = firestore.DocumentData>
96100
this._firestore._databaseId,
97101
/* timestampsInSnapshots= */ true,
98102
/* serverTimestampBehavior=*/ 'none',
99-
key => new DocumentReference(this._firestore, key, this._converter)
103+
key =>
104+
new DocumentReference(this._firestore, key.path, this._converter)
100105
);
101106
return userDataWriter.convertValue(value);
102107
}

0 commit comments

Comments
 (0)