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

Class QuerySnapshot

packages/firebase-firestore/index.ios.ts:625–705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

623}
624
625export class QuerySnapshot implements IQuerySnapshot {
626 _native: FIRQuerySnapshot;
627
628 static fromNative(snapshot: FIRQuerySnapshot) {
629 if (snapshot instanceof FIRQuerySnapshot) {
630 const ss = new QuerySnapshot();
631 ss._native = snapshot;
632 return ss;
633 }
634 return null;
635 }
636
637 get docs() {
638 const documents = this.native.documents;
639 const count = documents.count;
640 const docs = [];
641 for (let i = 0; i < count; i++) {
642 docs.push(QueryDocumentSnapshot.fromNative(documents.objectAtIndex(i)));
643 }
644 return docs;
645 }
646
647 get empty(): boolean {
648 return this.native.empty;
649 }
650
651 get metadata(): SnapshotMetadata {
652 return SnapshotMetadata.fromNative(this.native.metadata);
653 }
654
655 get query() {
656 return Query.fromNative(this.native.query);
657 }
658
659 get size(): number {
660 return this.native.count;
661 }
662
663 docChanges(options?: SnapshotListenOptions): DocumentChange[] {
664 let changes: NSArray<FIRDocumentChange>;
665 if (typeof options?.includeMetadataChanges === 'boolean') {
666 changes = this.native.documentChangesWithIncludeMetadataChanges(options.includeMetadataChanges);
667 } else {
668 changes = this.native.documentChanges;
669 }
670
671 const count = changes.count;
672 const docChanges = [];
673 for (let i = 0; i < count; i++) {
674 docChanges.push(DocumentChange.fromNative(changes.objectAtIndex(i)));
675 }
676 return docChanges;
677 }
678
679 forEach(callback: (result: QueryDocumentSnapshot, index: number) => void, thisArg?: any): void {
680 if (typeof callback === 'function') {
681 const cb = thisArg ? callback.bind(thisArg) : callback;
682 const count = this.native.count;

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…