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

Class CollectionReference

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

Source from the content-addressed store, hash-verified

766}
767
768export class CollectionReference<T extends DocumentData = DocumentData> extends Query<T> implements ICollectionReference<T> {
769 _native: com.google.firebase.firestore.CollectionReference;
770
771 static fromNative(collection: com.google.firebase.firestore.CollectionReference) {
772 if (collection instanceof com.google.firebase.firestore.CollectionReference) {
773 const nativeCollection = new CollectionReference();
774 nativeCollection._native = collection;
775 return nativeCollection;
776 }
777 return null;
778 }
779
780 get id(): string {
781 return this.native.getId();
782 }
783
784 get parent(): DocumentReference {
785 return DocumentReference.fromNative(this.native.getParent());
786 }
787
788 get path(): string {
789 return this.native.getPath();
790 }
791
792 add(data: T) {
793 return new Promise<DocumentReference<T>>((resolve, reject) => {
794 org.nativescript.firebase.firestore.FirebaseFirestore.CollectionReference.add(
795 this.native,
796 serializeItems(data),
797 new org.nativescript.firebase.firestore.FirebaseFirestore.Callback<com.google.firebase.firestore.DocumentReference>({
798 onSuccess(ref) {
799 resolve(DocumentReference.fromNative(ref));
800 },
801 onError(error) {
802 reject(FirebaseError.fromNative(error));
803 },
804 })
805 );
806 });
807 }
808
809 doc(documentPath?: string) {
810 return DocumentReference.fromNative(documentPath ? this.native.document(documentPath) : this.native.document());
811 }
812
813 toJSON() {
814 return {
815 id: this.id,
816 path: this.path,
817 parent: this.parent,
818 };
819 }
820
821 get native() {
822 return this._native;
823 }
824
825 get android() {

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…