MCPcopy Create free account
hub / github.com/NativeScript/firebase / DocumentReference

Class DocumentReference

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

Source from the content-addressed store, hash-verified

828}
829
830export class DocumentReference<T extends DocumentData = DocumentData> implements IDocumentReference<T> {
831 _native: com.google.firebase.firestore.DocumentReference;
832
833 static fromNative(document: com.google.firebase.firestore.DocumentReference) {
834 if (document instanceof com.google.firebase.firestore.DocumentReference) {
835 const doc = new DocumentReference();
836 doc._native = document;
837 return doc;
838 }
839 return null;
840 }
841
842 get firestore(): Firestore {
843 return Firestore.fromNative(this.native.getFirestore());
844 }
845
846 get id(): string {
847 return this.native.getId();
848 }
849
850 get parent() {
851 return CollectionReference.fromNative(this.native.getParent());
852 }
853
854 get path(): string {
855 return this.native.getPath();
856 }
857
858 collection(collectionPath: string) {
859 return CollectionReference.fromNative(this.native.collection(collectionPath));
860 }
861
862 delete(): Promise<void> {
863 return new Promise((resolve, reject) => {
864 org.nativescript.firebase.firestore.FirebaseFirestore.DocumentReference.delete(
865 this.native,
866 new org.nativescript.firebase.firestore.FirebaseFirestore.Callback<java.lang.Void>({
867 onSuccess(param0) {
868 resolve();
869 },
870 onError(error) {
871 reject(FirebaseError.fromNative(error));
872 },
873 })
874 );
875 });
876 }
877
878 get(options?: GetOptions): Promise<DocumentSnapshot<T>> {
879 return new Promise((resolve, reject) => {
880 let source: com.google.firebase.firestore.Source;
881 switch (options) {
882 case GetOptions.Cache:
883 source = com.google.firebase.firestore.Source.CACHE;
884 break;
885 case GetOptions.Server:
886 source = com.google.firebase.firestore.Source.SERVER;
887 break;

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…