Stay organized with collections Save and categorize content based on your preferences.
A VectorQuerySnapshot
contains zero or more QueryDocumentSnapshot
objects representing the results of a query. The documents can be accessed as an array via the docs
property or enumerated using the forEach
method. The number of documents can be determined via the empty
and size
properties.
get docs(): Array<QueryDocumentSnapshot<AppModelType, DbModelType>>;
An array of all the documents in this VectorQuerySnapshot
.
let query = firestore.collection('col')
.findNearest("embedding", [0, 0], {limit: 10, distanceMeasure: "EUCLIDEAN"});
query.get().then(querySnapshot => {
let docs = querySnapshot.docs;
for (let doc of docs) {
console.log(`Document found at path: ${doc.ref.path}`);
}
});
empty
true
if there are no documents in the VectorQuerySnapshot
.
let query = firestore.collection('col')
.findNearest("embedding", [0, 0], {limit: 10, distanceMeasure: "EUCLIDEAN"});
query.get().then(querySnapshot => {
if (querySnapshot.empty) {
console.log('No documents found.');
}
});
query
get query(): VectorQuery<AppModelType, DbModelType>;
The VectorQuery
on which you called get() in order to get this VectorQuerySnapshot
.
let query = firestore.collection('col').where('foo', '==', 'bar');
query.findNearest("embedding", [0, 0], {limit: 10, distanceMeasure: "EUCLIDEAN"})
.get().then(querySnapshot => {
console.log(`Returned first batch of results`);
let query = querySnapshot.query;
return query.offset(10).get();
}).then(() => {
console.log(`Returned second batch of results`);
});
readTime
get readTime(): Timestamp;
The time this VectorQuerySnapshot
was obtained.
let query = firestore.collection('col')
.findNearest("embedding", [0, 0], {limit: 10, distanceMeasure: "EUCLIDEAN"});
query.get().then((querySnapshot) => {
let readTime = querySnapshot.readTime;
console.log(`Query results returned at '${readTime.toDate()}'`);
});
size
The number of documents in the VectorQuerySnapshot
.
let query = firestore.collection('col')
.findNearest("embedding", [0, 0], {limit: 10, distanceMeasure: "EUCLIDEAN"});
query.get().then(querySnapshot => {
console.log(`Found ${querySnapshot.size} documents.`);
});
Methods docChanges()
docChanges(): Array<DocumentChange<AppModelType, DbModelType>>;
Returns an array of the documents changes since the last snapshot. If this is the first snapshot, all documents will be in the list as added changes.
Returns Type DescriptionArray<DocumentChange<AppModelType, DbModelType>>
An array of the documents changes since the last snapshot.
Example
let query = firestore.collection('col')
.findNearest("embedding", [0, 0], {limit: 10, distanceMeasure: "EUCLIDEAN"});
query.get().then(querySnapshot => {
let changes = querySnapshot.docChanges();
for (let change of changes) {
console.log(`A document was ${change.type}.`);
}
});
forEach(callback, thisArg)
forEach(callback: (result: firestore.QueryDocumentSnapshot<AppModelType, DbModelType>) => void, thisArg?: unknown): void;
Enumerates all of the documents in the VectorQuerySnapshot
. This is a convenience method for running the same callback on each QueryDocumentSnapshot that is returned.
callback
(result: FirebaseFirestore.QueryDocumentSnapshot<AppModelType, DbModelType>) => void
A callback to be called with a QueryDocumentSnapshot for each document in the snapshot.
thisArg
unknown
The this
binding for the callback..
void
Example
let query = firestore.collection('col')
.findNearest("embedding", [0, 0], {limit: 10, distanceMeasure: "EUCLIDEAN"});
query.get().then(querySnapshot => {
querySnapshot.forEach(documentSnapshot => {
console.log(`Document found at path: ${documentSnapshot.ref.path}`);
});
});
isEqual(other)
isEqual(other: firestore.VectorQuerySnapshot<AppModelType, DbModelType>): boolean;
Returns true if the document data in this VectorQuerySnapshot
is equal to the provided value.
other
FirebaseFirestore.VectorQuerySnapshot<AppModelType, DbModelType>
The value to compare against.
Returns Type Descriptionboolean
true if this VectorQuerySnapshot
is equal to the provided value.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4