MCPcopy Index your code
hub / github.com/NativeScript/firebase / DocumentSnapshot

Class DocumentSnapshot

packages/firebase-firestore/index.android.ts:327–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325}
326
327export class DocumentSnapshot<T extends DocumentData = DocumentData> implements IDocumentSnapshot<T> {
328 _native: com.google.firebase.firestore.DocumentSnapshot;
329
330 static fromNative(snapshot: com.google.firebase.firestore.DocumentSnapshot) {
331 if (snapshot instanceof com.google.firebase.firestore.DocumentSnapshot) {
332 const ss = new DocumentSnapshot();
333 ss._native = snapshot;
334 return ss;
335 }
336 return null;
337 }
338
339 get exists(): boolean {
340 return this.native.exists();
341 }
342
343 get id(): string {
344 return this.native.getId();
345 }
346
347 get metadata(): SnapshotMetadata {
348 return SnapshotMetadata.fromNative(this.native.getMetadata());
349 }
350
351 get ref(): DocumentReference {
352 return DocumentReference.fromNative(this.native.getReference());
353 }
354
355 data() {
356 return deserializeField(this.native.getData());
357 }
358
359 get<fieldType extends DocumentFieldType>(fieldPath: string | number | FieldPath): fieldType {
360 if (fieldPath instanceof FieldPath) {
361 return deserializeField(this.native.get(fieldPath?.native));
362 } else {
363 return deserializeField(this.native.get(String(fieldPath)));
364 }
365 }
366
367 toJSON() {
368 return {
369 exists: this.exists,
370 id: this.id,
371 metadata: this.metadata,
372 ref: this.ref,
373 data: this.data,
374 };
375 }
376
377 get native() {
378 return this._native;
379 }
380
381 get android() {
382 return this.native;
383 }
384}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…