क्वेरी कर्सर के साथ डेटा पृष्ठांकित करें

क्लाउड फायरस्टोर में क्वेरी कर्सर के साथ, आप क्वेरी द्वारा लौटाए गए डेटा को अपनी क्वेरी में परिभाषित मापदंडों के अनुसार बैचों में विभाजित कर सकते हैं।

क्वेरी कर्सर किसी क्वेरी के लिए आरंभ और अंत बिंदुओं को परिभाषित करते हैं, जिससे आप:

  • डेटा का एक उपसमूह लौटाएँ.
  • क्वेरी परिणाम पृष्ठांकित करें.

हालाँकि, किसी क्वेरी के लिए एक विशिष्ट श्रेणी को परिभाषित करने के लिए, आपको Simple Queries में वर्णित where() विधि का उपयोग करना चाहिए।

किसी क्वेरी में एक साधारण कर्सर जोड़ें

किसी क्वेरी के लिए प्रारंभ बिंदु को परिभाषित करने के लिए startAt() या startAfter() विधियों का उपयोग करें। startAt() विधि में प्रारंभ बिंदु शामिल है, जबकि startAfter() विधि में इसे शामिल नहीं किया गया है।

उदाहरण के लिए, यदि आप किसी क्वेरी में startAt(A) उपयोग करते हैं, तो यह संपूर्ण वर्णमाला लौटाता है। यदि आप इसके बजाय startAfter(A) उपयोग करते हैं, तो यह BZ लौटाता है।

Web modular API

import { query, orderBy, startAt } from "firebase/firestore";  

const q = query(citiesRef, orderBy("population"), startAt(1000000));

Web namespaced API

citiesRef.orderBy("population").startAt(1000000);
तीव्र
नोट: यह उत्पाद वॉचओएस और ऐप क्लिप लक्ष्य पर उपलब्ध नहीं है।
// Get all cities with population over one million, ordered by population.
db.collection("cities")
  .order(by: "population")
  .start(at: [1000000])
उद्देश्य सी
नोट: यह उत्पाद वॉचओएस और ऐप क्लिप लक्ष्य पर उपलब्ध नहीं है।
// Get all cities with population over one million, ordered by population.
[[[db collectionWithPath:@"cities"]
    queryOrderedByField:@"population"]
    queryStartingAtValues:@[ @1000000 ]];

Kotlin+KTX

// Get all cities with a population >= 1,000,000, ordered by population,
db.collection("cities")
    .orderBy("population")
    .startAt(1000000)

Java

// Get all cities with a population >= 1,000,000, ordered by population,
db.collection("cities")
        .orderBy("population")
        .startAt(1000000);

Dart

db.collection("cities").orderBy("population").startAt([1000000]);
जावा
Query query = cities.orderBy("population").startAt(4921000L);
अजगर
cities_ref = db.collection("cities")
query_start_at = cities_ref.order_by("population").start_at({"population": 1000000})

Python

cities_ref = db.collection("cities")
query_start_at = cities_ref.order_by("population").start_at({"population": 1000000})
सी++
// Get all cities with a population >= 1,000,000, ordered by population,
db->Collection("cities")
    .OrderBy("population")
    .StartAt({FieldValue::Integer(1000000)});
नोड.जे.एस
const startAtRes = await db.collection('cities')
  .orderBy('population')
  .startAt(1000000)
  .get();
जाना
query := client.Collection("cities").OrderBy("population", firestore.Asc).StartAt(1000000)
पीएचपी

पीएचपी

क्लाउड फायरस्टोर क्लाइंट स्थापित करने और बनाने के बारे में अधिक जानकारी के लिए, क्लाउड फायरस्टोर क्लाइंट लाइब्रेरीज़ देखें।

$query = $citiesRef
    ->orderBy('population')
    ->startAt([1000000]);
एकता
Query query = citiesRef.OrderBy("Population").StartAt(1000000);
सी#
Query query = citiesRef.OrderBy("Population").StartAt(1000000);
माणिक
query = cities_ref.order("population").start_at(1_000_000)

इसी तरह, अपने क्वेरी परिणामों के लिए अंतिम बिंदु को परिभाषित करने के लिए endAt() या endBefore() तरीकों का उपयोग करें।

Web modular API

import { query, orderBy, endAt } from "firebase/firestore";  

const q = query(citiesRef, orderBy("population"), endAt(1000000));

Web namespaced API

citiesRef.orderBy("population").endAt(1000000);
तीव्र
नोट: यह उत्पाद वॉचओएस और ऐप क्लिप लक्ष्य पर उपलब्ध नहीं है।
// Get all cities with population less than one million, ordered by population.
db.collection("cities")
  .order(by: "population")
  .end(at: [1000000])
उद्देश्य सी
नोट: यह उत्पाद वॉचओएस और ऐप क्लिप लक्ष्य पर उपलब्ध नहीं है।
// Get all cities with population less than one million, ordered by population.
[[[db collectionWithPath:@"cities"]
    queryOrderedByField:@"population"]
    queryEndingAtValues:@[ @1000000 ]];

Kotlin+KTX

// Get all cities with a population <= 1,000,000, ordered by population,
db.collection("cities")
    .orderBy("population")
    .endAt(1000000)

Java

// Get all cities with a population <= 1,000,000, ordered by population,
db.collection("cities")
        .orderBy("population")
        .endAt(1000000);

Dart

db.collection("cities").orderBy("population").endAt([1000000]);
जावा
Query query = cities.orderBy("population").endAt(4921000L);
अजगर
cities_ref = db.collection("cities")
query_end_at = cities_ref.order_by("population").end_at({"population": 1000000})

Python

cities_ref = db.collection("cities")
query_end_at = cities_ref.order_by("population").end_at({"population": 1000000})
सी++
// Get all cities with a population <= 1,000,000, ordered by population,
db->Collection("cities")
    .OrderBy("population")
    .EndAt({FieldValue::Integer(1000000)});
नोड.जे.एस
const endAtRes = await db.collection('cities')
  .orderBy('population')
  .endAt(1000000)
  .get();
जाना
query := client.Collection("cities").OrderBy("population", firestore.Asc).EndAt(1000000)
पीएचपी

पीएचपी

क्लाउड फायरस्टोर क्लाइंट स्थापित करने और बनाने के बारे में अधिक जानकारी के लिए, क्लाउड फायरस्टोर क्लाइंट लाइब्रेरीज़ देखें।

$query = $citiesRef
    ->orderBy('population')
    ->endAt([1000000]);
एकता
Query query = citiesRef.OrderBy("Population").EndAt(1000000);
सी#
Query query = citiesRef.OrderBy("Population").EndAt(1000000);
माणिक
query = cities_ref.order("population").end_at(1_000_000)

क्वेरी कर्सर को परिभाषित करने के लिए दस्तावेज़ स्नैपशॉट का उपयोग करें

आप क्वेरी कर्सर के प्रारंभ या अंत बिंदु के रूप में कर्सर क्लॉज पर एक दस्तावेज़ स्नैपशॉट भी पास कर सकते हैं। दस्तावेज़ स्नैपशॉट में मान क्वेरी कर्सर में मान के रूप में कार्य करते हैं।

उदाहरण के लिए, अपने शहरों और आबादी के डेटा सेट में "सैन फ्रांसिस्को" दस्तावेज़ का एक स्नैपशॉट लें। फिर, उस दस्तावेज़ स्नैपशॉट को अपने जनसंख्या क्वेरी कर्सर के लिए प्रारंभ बिंदु के रूप में उपयोग करें। आपकी क्वेरी सैन फ्रांसिस्को से बड़ी या उसके बराबर आबादी वाले सभी शहरों को वापस कर देगी, जैसा कि दस्तावेज़ स्नैपशॉट में परिभाषित किया गया है।

Web modular API

import { collection, doc, getDoc, query, orderBy, startAt } from "firebase/firestore";  
const citiesRef = collection(db, "cities");

const docSnap = await getDoc(doc(citiesRef, "SF"));

// Get all cities with a population bigger than San Francisco
const biggerThanSf = query(citiesRef, orderBy("population"), startAt(docSnap));
// ...

Web namespaced API

var citiesRef = db.collection("cities");

return citiesRef.doc("SF").get().then((doc) => {
    // Get all cities with a population bigger than San Francisco
    var biggerThanSf = citiesRef
        .orderBy("population")
        .startAt(doc);

    // ...
});
तीव्र
नोट: यह उत्पाद वॉचओएस और ऐप क्लिप लक्ष्य पर उपलब्ध नहीं है।
db.collection("cities")
  .document("SF")
  .addSnapshotListener { (document, error) in
    guard let document = document else {
      print("Error retreving cities: \(error.debugDescription)")
      return
    }

    // Get all cities with a population greater than or equal to San Francisco.
    let sfSizeOrBigger = db.collection("cities")
      .order(by: "population")
      .start(atDocument: document)
  }
उद्देश्य सी
नोट: यह उत्पाद वॉचओएस और ऐप क्लिप लक्ष्य पर उपलब्ध नहीं है।
[[[db collectionWithPath:@"cities"] documentWithPath:@"SF"]
    addSnapshotListener:^(FIRDocumentSnapshot *snapshot, NSError *error) {
      if (snapshot == nil) {
        NSLog(@"Error retreiving cities: %@", error);
        return;
      }
      // Get all cities with a population greater than or equal to San Francisco.
      FIRQuery *sfSizeOrBigger = [[[db collectionWithPath:@"cities"]
          queryOrderedByField:@"population"]
          queryStartingAtDocument:snapshot];
    }];

Kotlin+KTX

// Get the data for "San Francisco"
db.collection("cities").document("SF")
    .get()
    .addOnSuccessListener { documentSnapshot ->
        // Get all cities with a population bigger than San Francisco.
        val biggerThanSf = db.collection("cities")
            .orderBy("population")
            .startAt(documentSnapshot)

        // ...
    }

Java

// Get the data for "San Francisco"
db.collection("cities").document("SF")
        .get()
        .addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
            @Override
            public void onSuccess(DocumentSnapshot documentSnapshot) {
                // Get all cities with a population bigger than San Francisco.
                Query biggerThanSf = db.collection("cities")
                        .orderBy("population")
                        .startAt(documentSnapshot);

                // ...
            }
        });

Dart

db.collection("cities").doc("SF").get().then(
  (documentSnapshot) {
    final biggerThanSf = db
        .collection("cities")
        .orderBy("population")
        .startAtDocument(documentSnapshot);
  },
  onError: (e) => print("Error: $e"),
);
जावा
// Fetch the snapshot with an API call, waiting for a maximum of 30 seconds for a result.
ApiFuture<DocumentSnapshot> future = db.collection("cities").document("SF").get();
DocumentSnapshot snapshot = future.get(30, TimeUnit.SECONDS);

// Construct the query
Query query = db.collection("cities").orderBy("population").startAt(snapshot);
अजगर
doc_ref = db.collection("cities").document("SF")

snapshot = doc_ref.get()
start_at_snapshot = (
    db.collection("cities").order_by("population").start_at(snapshot)
)

Python

doc_ref = db.collection("cities").document("SF")

snapshot = await doc_ref.get()
start_at_snapshot = (
    db.collection("cities").order_by("population").start_at(snapshot)
)
सी++
db->Collection("cities").Document("SF").Get().OnCompletion(
    [db](const Future<DocumentSnapshot>& future) {
      if (future.error() == Error::kErrorOk) {
        const DocumentSnapshot& document_snapshot = *future.result();
        Query bigger_than_sf = db->Collection("cities")
                                   .OrderBy("population")
                                   .StartAt({document_snapshot});
        // ...
      }
    });
नोड.जे.एस
const docRef = db.collection('cities').doc('SF');
const snapshot = await docRef.get();
const startAtSnapshot = db.collection('cities')
  .orderBy('population')
  .startAt(snapshot);

await startAtSnapshot.limit(10).get();
जाना
cities := client.Collection("cities")
dsnap, err := cities.Doc("SF").Get(ctx)
if err != nil {
	fmt.Println(err)
}
query := cities.OrderBy("population", firestore.Asc).StartAt(dsnap.Data()["population"]).Documents(ctx)
पीएचपी

पीएचपी

क्लाउड फायरस्टोर क्लाइंट स्थापित करने और बनाने के बारे में अधिक जानकारी के लिए, क्लाउड फायरस्टोर क्लाइंट लाइब्रेरीज़ देखें।

$citiesRef = $db->collection('samples/php/cities');
$docRef = $citiesRef->document('SF');
$snapshot = $docRef->snapshot();

$query = $citiesRef
    ->orderBy('population')
    ->startAt($snapshot);
एकता
CollectionReference citiesRef = db.Collection("cities");
DocumentReference docRef = citiesRef.Document("SF");
docRef.GetSnapshotAsync().ContinueWith((snapshotTask) =>
{
    Query query = citiesRef.OrderBy("Population").StartAt(snapshotTask.Result);
});
सी#
CollectionReference citiesRef = db.Collection("cities");
DocumentReference docRef = citiesRef.Document("SF");
DocumentSnapshot snapshot = await docRef.GetSnapshotAsync();
Query query = citiesRef.OrderBy("Population").StartAt(snapshot);
माणिक
doc_ref = firestore.doc "#{collection_path}/SF"
snapshot = doc_ref.get
query = cities_ref.order("population").start_at(snapshot)

किसी क्वेरी को पेजिनेट करें

limit() विधि के साथ क्वेरी कर्सर को संयोजित करके प्रश्नों को पेजिनेट करें। उदाहरण के लिए, किसी बैच में अंतिम दस्तावेज़ को अगले बैच के लिए कर्सर की शुरुआत के रूप में उपयोग करें।

Web modular API

import { collection, query, orderBy, startAfter, limit, getDocs } from "firebase/firestore";  

// Query the first page of docs
const first = query(collection(db, "cities"), orderBy("population"), limit(25));
const documentSnapshots = await getDocs(first);

// Get the last visible document
const lastVisible = documentSnapshots.docs[documentSnapshots.docs.length-1];
console.log("last", lastVisible);

// Construct a new query starting at this document,
// get the next 25 cities.
const next = query(collection(db, "cities"),
    orderBy("population"),
    startAfter(lastVisible),
    limit(25));

Web namespaced API

var first = db.collection("cities")
        .orderBy("population")
        .limit(25);

return first.get().then((documentSnapshots) => {
  // Get the last visible document
  var lastVisible = documentSnapshots.docs[documentSnapshots.docs.length-1];
  console.log("last", lastVisible);

  // Construct a new query starting at this document,
  // get the next 25 cities.
  var next = db.collection("cities")
          .orderBy("population")
          .startAfter(lastVisible)
          .limit(25);
});
तीव्र
नोट: यह उत्पाद वॉचओएस और ऐप क्लिप लक्ष्य पर उपलब्ध नहीं है।
// Construct query for first 25 cities, ordered by population
let first = db.collection("cities")
  .order(by: "population")
  .limit(to: 25)

first.addSnapshotListener { (snapshot, error) in
  guard let snapshot = snapshot else {
    print("Error retreving cities: \(error.debugDescription)")
    return
  }

  guard let lastSnapshot = snapshot.documents.last else {
    // The collection is empty.
    return
  }

  // Construct a new query starting after this document,
  // retrieving the next 25 cities.
  let next = db.collection("cities")
    .order(by: "population")
    .start(afterDocument: lastSnapshot)

  // Use the query for pagination.
  // ...
}
उद्देश्य सी
नोट: यह उत्पाद वॉचओएस और ऐप क्लिप लक्ष्य पर उपलब्ध नहीं है।
FIRQuery *first = [[[db collectionWithPath:@"cities"]
    queryOrderedByField:@"population"]
    queryLimitedTo:25];
[first addSnapshotListener:^(FIRQuerySnapshot *snapshot, NSError *error) {
  if (snapshot == nil) {
    NSLog(@"Error retreiving cities: %@", error);
    return;
  }
  if (snapshot.documents.count == 0) { return; }
  FIRDocumentSnapshot *lastSnapshot = snapshot.documents.lastObject;

  // Construct a new query starting after this document,
  // retreiving the next 25 cities.
  FIRQuery *next = [[[db collectionWithPath:@"cities"]
      queryOrderedByField:@"population"]
      queryStartingAfterDocument:lastSnapshot];
  // Use the query for pagination.
  // ...
}];

Kotlin+KTX

// Construct query for first 25 cities, ordered by population
val first = db.collection("cities")
    .orderBy("population")
    .limit(25)

first.get()
    .addOnSuccessListener { documentSnapshots ->
        // ...

        // Get the last visible document
        val lastVisible = documentSnapshots.documents[documentSnapshots.size() - 1]

        // Construct a new query starting at this document,
        // get the next 25 cities.
        val next = db.collection("cities")
            .orderBy("population")
            .startAfter(lastVisible)
            .limit(25)

        // Use the query for pagination
        // ...
    }

Java

// Construct query for first 25 cities, ordered by population
Query first = db.collection("cities")
        .orderBy("population")
        .limit(25);

first.get()
    .addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
        @Override
        public void onSuccess(QuerySnapshot documentSnapshots) {
            // ...

            // Get the last visible document
            DocumentSnapshot lastVisible = documentSnapshots.getDocuments()
                    .get(documentSnapshots.size() -1);

            // Construct a new query starting at this document,
            // get the next 25 cities.
            Query next = db.collection("cities")
                    .orderBy("population")
                    .startAfter(lastVisible)
                    .limit(25);

            // Use the query for pagination
            // ...
        }
    });

Dart

// Construct query for first 25 cities, ordered by population
final first = db.collection("cities").orderBy("population").limit(25);

first.get().then(
  (documentSnapshots) {
    // Get the last visible document
    final lastVisible = documentSnapshots.docs[documentSnapshots.size - 1];

    // Construct a new query starting at this document,
    // get the next 25 cities.
    final next = db
        .collection("cities")
        .orderBy("population")
        .startAfterDocument(lastVisible).limit(25);

    // Use the query for pagination
    // ...
  },
  onError: (e) => print("Error completing: $e"),
);
जावा
// Construct query for first 25 cities, ordered by population.
CollectionReference cities = db.collection("cities");
Query firstPage = cities.orderBy("population").limit(25);

// Wait for the results of the API call, waiting for a maximum of 30 seconds for a result.
ApiFuture<QuerySnapshot> future = firstPage.get();
List<QueryDocumentSnapshot> docs = future.get(30, TimeUnit.SECONDS).getDocuments();

// Construct query for the next 25 cities.
QueryDocumentSnapshot lastDoc = docs.get(docs.size() - 1);
Query secondPage = cities.orderBy("population").startAfter(lastDoc).limit(25);

future = secondPage.get();
docs = future.get(30, TimeUnit.SECONDS).getDocuments();
अजगर
cities_ref = db.collection("cities")
first_query = cities_ref.order_by("population").limit(3)

# Get the last document from the results
docs = first_query.stream()
last_doc = list(docs)[-1]

# Construct a new query starting at this document
# Note: this will not have the desired effect if
# multiple cities have the exact same population value
last_pop = last_doc.to_dict()["population"]

next_query = (
    cities_ref.order_by("population").start_after({"population": last_pop}).limit(3)
)
# Use the query for pagination
# ...

Python

cities_ref = db.collection("cities")
first_query = cities_ref.order_by("population").limit(3)

# Get the last document from the results
docs = [d async for d in first_query.stream()]
last_doc = list(docs)[-1]

# Construct a new query starting at this document
# Note: this will not have the desired effect if
# multiple cities have the exact same population value
last_pop = last_doc.to_dict()["population"]

next_query = (
    cities_ref.order_by("population").start_after({"population": last_pop}).limit(3)
)
# Use the query for pagination
# ...
सी++
// Construct query for first 25 cities, ordered by population
Query first = db->Collection("cities").OrderBy("population").Limit(25);

first.Get().OnCompletion([db](const Future<QuerySnapshot>& future) {
  if (future.error() != Error::kErrorOk) {
    // Handle error...
    return;
  }

  // Get the last visible document
  const QuerySnapshot& document_snapshots = *future.result();
  std::vector<DocumentSnapshot> documents = document_snapshots.documents();
  const DocumentSnapshot& last_visible = documents.back();

  // Construct a new query starting at this document,
  // get the next 25 cities.
  Query next = db->Collection("cities")
                   .OrderBy("population")
                   .StartAfter(last_visible)
                   .Limit(25);

  // Use the query for pagination
  // ...
});
नोड.जे.एस
const first = db.collection('cities')
  .orderBy('population')
  .limit(3);

const snapshot = await first.get();

// Get the last document
const last = snapshot.docs[snapshot.docs.length - 1];

// Construct a new query starting at this document.
// Note: this will not have the desired effect if multiple
// cities have the exact same population value.
const next = db.collection('cities')
  .orderBy('population')
  .startAfter(last.data().population)
  .limit(3);

// Use the query for pagination
// ...
जाना
cities := client.Collection("cities")

// Get the first 25 cities, ordered by population.
firstPage := cities.OrderBy("population", firestore.Asc).Limit(25).Documents(ctx)
docs, err := firstPage.GetAll()
if err != nil {
	return err
}

// Get the last document.
lastDoc := docs[len(docs)-1]

// Construct a new query to get the next 25 cities.
secondPage := cities.OrderBy("population", firestore.Asc).
	StartAfter(lastDoc.Data()["population"]).
	Limit(25)

// ...
पीएचपी

पीएचपी

क्लाउड फायरस्टोर क्लाइंट स्थापित करने और बनाने के बारे में अधिक जानकारी के लिए, क्लाउड फायरस्टोर क्लाइंट लाइब्रेरीज़ देखें।

$citiesRef = $db->collection('samples/php/cities');
$firstQuery = $citiesRef->orderBy('population')->limit(3);

# Get the last document from the results
$documents = $firstQuery->documents();
$lastPopulation = 0;
foreach ($documents as $document) {
    $lastPopulation = $document['population'];
}

# Construct a new query starting at this document
# Note: this will not have the desired effect if multiple cities have the exact same population value
$nextQuery = $citiesRef->orderBy('population')->startAfter([$lastPopulation]);
$snapshot = $nextQuery->documents();
एकता
CollectionReference citiesRef = db.Collection("cities");
Query firstQuery = citiesRef.OrderBy("Population").Limit(3);

// Get the last document from the results
firstQuery.GetSnapshotAsync().ContinueWith((querySnapshotTask) =>
{
    long lastPopulation = 0;
    foreach (DocumentSnapshot documentSnapshot in querySnapshotTask.Result.Documents)
    {
        lastPopulation = documentSnapshot.GetValue<long>("Population");
    }

    // Construct a new query starting at this document.
    // Note: this will not have the desired effect if multiple cities have the exact same population value
    Query secondQuery = citiesRef.OrderBy("Population").StartAfter(lastPopulation);
    Task<QuerySnapshot> secondQuerySnapshot = secondQuery.GetSnapshotAsync();
सी#
CollectionReference citiesRef = db.Collection("cities");
Query firstQuery = citiesRef.OrderBy("Population").Limit(3);

// Get the last document from the results
QuerySnapshot querySnapshot = await firstQuery.GetSnapshotAsync();
long lastPopulation = 0;
foreach (DocumentSnapshot documentSnapshot in querySnapshot.Documents)
{
    lastPopulation = documentSnapshot.GetValue<long>("Population");
}

// Construct a new query starting at this document.
// Note: this will not have the desired effect if multiple cities have the exact same population value
Query secondQuery = citiesRef.OrderBy("Population").StartAfter(lastPopulation);
QuerySnapshot secondQuerySnapshot = await secondQuery.GetSnapshotAsync();
माणिक
cities_ref  = firestore.col collection_path
first_query = cities_ref.order("population").limit(3)

# Get the last document from the results.
last_population = 0
first_query.get do |city|
  last_population = city.data[:population]
end

# Construct a new query starting at this document.
# Note: this will not have the desired effect if multiple cities have the exact same population value.
second_query = cities_ref.order("population").start_after(last_population)
second_query.get do |city|
  puts "Document #{city.document_id} returned by paginated query cursor."
end

एकाधिक फ़ील्ड के आधार पर कर्सर सेट करें

फ़ील्ड मान (डॉक्यूमेंटस्नैपशॉट नहीं) के आधार पर कर्सर का उपयोग करते समय, आप अतिरिक्त फ़ील्ड जोड़कर कर्सर की स्थिति को अधिक सटीक बना सकते हैं। यह विशेष रूप से उपयोगी है यदि आपके डेटा सेट में कई दस्तावेज़ शामिल हैं जिनमें आपके कर्सर फ़ील्ड के लिए सभी का मान समान है, जिससे कर्सर की स्थिति अस्पष्ट हो जाती है। आप प्रारंभ या समाप्ति बिंदु को और अधिक निर्दिष्ट करने और अस्पष्टता को कम करने के लिए अपने कर्सर में अतिरिक्त फ़ील्ड मान जोड़ सकते हैं।

उदाहरण के लिए, संयुक्त राज्य अमेरिका में "स्प्रिंगफील्ड" नाम के सभी शहरों वाले डेटा सेट में, "स्प्रिंगफील्ड" से शुरू होने वाले क्वेरी सेट के लिए कई प्रारंभ बिंदु होंगे:

शहरों
नाम राज्य
स्प्रिंगफील्ड मैसाचुसेट्स
स्प्रिंगफील्ड मिसौरी
स्प्रिंगफील्ड विस्कॉन्सिन

किसी विशिष्ट स्प्रिंगफ़ील्ड से प्रारंभ करने के लिए, आप अपने कर्सर क्लॉज़ में राज्य को द्वितीयक शर्त के रूप में जोड़ सकते हैं।

Web modular API

// Will return all Springfields
import { collection, query, orderBy, startAt } from "firebase/firestore";  
const q1 = query(collection(db, "cities"),
   orderBy("name"),
   orderBy("state"),
   startAt("Springfield"));

// Will return "Springfield, Missouri" and "Springfield, Wisconsin"
const q2 = query(collection(db, "cities"),
   orderBy("name"),
   orderBy("state"),
   startAt("Springfield", "Missouri"));

Web namespaced API

// Will return all Springfields
db.collection("cities")
   .orderBy("name")
   .orderBy("state")
   .startAt("Springfield");

// Will return "Springfield, Missouri" and "Springfield, Wisconsin"
db.collection("cities")
   .orderBy("name")
   .orderBy("state")
   .startAt("Springfield", "Missouri");
तीव्र
नोट: यह उत्पाद वॉचओएस और ऐप क्लिप लक्ष्य पर उपलब्ध नहीं है।
// Will return all Springfields
db.collection("cities")
  .order(by: "name")
  .order(by: "state")
  .start(at: ["Springfield"])

// Will return "Springfield, Missouri" and "Springfield, Wisconsin"
db.collection("cities")
  .order(by: "name")
  .order(by: "state")
  .start(at: ["Springfield", "Missouri"])
उद्देश्य सी
नोट: यह उत्पाद वॉचओएस और ऐप क्लिप लक्ष्य पर उपलब्ध नहीं है।
// Will return all Springfields
[[[[db collectionWithPath:@"cities"]
    queryOrderedByField:@"name"]
    queryOrderedByField:@"state"]
    queryStartingAtValues:@[ @"Springfield" ]];
// Will return "Springfield, Missouri" and "Springfield, Wisconsin"
[[[[db collectionWithPath:@"cities"]
   queryOrderedByField:@"name"]
   queryOrderedByField:@"state"]
   queryStartingAtValues:@[ @"Springfield", @"Missouri" ]];

Kotlin+KTX

// Will return all Springfields
db.collection("cities")
    .orderBy("name")
    .orderBy("state")
    .startAt("Springfield")

// Will return "Springfield, Missouri" and "Springfield, Wisconsin"
db.collection("cities")
    .orderBy("name")
    .orderBy("state")
    .startAt("Springfield", "Missouri")

Java

// Will return all Springfields
db.collection("cities")
        .orderBy("name")
        .orderBy("state")
        .startAt("Springfield");

// Will return "Springfield, Missouri" and "Springfield, Wisconsin"
db.collection("cities")
        .orderBy("name")
        .orderBy("state")
        .startAt("Springfield", "Missouri");

Dart

// Will return all Springfields
db
    .collection("cities")
    .orderBy("name")
    .orderBy("state")
    .startAt(["Springfield"]);

// Will return "Springfield, Missouri" and "Springfield, Wisconsin"
db
    .collection("cities")
    .orderBy("name")
    .orderBy("state")
    .startAt(["Springfield", "Missouri"]);
जावा
// Will return all Springfields
Query query1 = db.collection("cities").orderBy("name").orderBy("state").startAt("Springfield");

// Will return "Springfield, Missouri" and "Springfield, Wisconsin"
Query query2 =
    db.collection("cities").orderBy("name").orderBy("state").startAt("Springfield", "Missouri");
अजगर
start_at_name = (
    db.collection("cities").order_by("name").start_at({"name": "Springfield"})
)

start_at_name_and_state = (
    db.collection("cities")
    .order_by("name")
    .order_by("state")
    .start_at({"name": "Springfield", "state": "Missouri"})
)

Python

start_at_name = (
    db.collection("cities")
    .order_by("name")
    .order_by("state")
    .start_at({"name": "Springfield"})
)

start_at_name_and_state = (
    db.collection("cities")
    .order_by("name")
    .order_by("state")
    .start_at({"name": "Springfield", "state": "Missouri"})
)
सी++
// This is not yet supported.
नोड.जे.एस
// Will return all Springfields
const startAtNameRes = await db.collection('cities')
  .orderBy('name')
  .orderBy('state')
  .startAt('Springfield')
  .get();

// Will return 'Springfield, Missouri' and 'Springfield, Wisconsin'
const startAtNameAndStateRes = await db.collection('cities')
  .orderBy('name')
  .orderBy('state')
  .startAt('Springfield', 'Missouri')
  .get();
जाना
// Will return all Springfields.
client.Collection("cities").
	OrderBy("name", firestore.Asc).
	OrderBy("state", firestore.Asc).
	StartAt("Springfield")

// Will return Springfields where state comes after Wisconsin.
client.Collection("cities").
	OrderBy("name", firestore.Asc).
	OrderBy("state", firestore.Asc).
	StartAt("Springfield", "Wisconsin")
पीएचपी

पीएचपी

क्लाउड फायरस्टोर क्लाइंट स्थापित करने और बनाने के बारे में अधिक जानकारी के लिए, क्लाउड फायरस्टोर क्लाइंट लाइब्रेरीज़ देखें।

// Will return all Springfields
$query1 = $db
    ->collection('samples/php/cities')
    ->orderBy('name')
    ->orderBy('state')
    ->startAt(['Springfield']);

// Will return "Springfield, Missouri" and "Springfield, Wisconsin"
$query2 = $db
    ->collection('samples/php/cities')
    ->orderBy('name')
    ->orderBy('state')
    ->startAt(['Springfield', 'Missouri']);
एकता
Query query1 = db.Collection("cities").OrderBy("Name").OrderBy("State").StartAt("Springfield");
Query query2 = db.Collection("cities").OrderBy("Name").OrderBy("State").StartAt("Springfield", "Missouri");
सी#
Query query1 = db.Collection("cities").OrderBy("Name").OrderBy("State").StartAt("Springfield");
Query query2 = db.Collection("cities").OrderBy("Name").OrderBy("State").StartAt("Springfield", "Missouri");
माणिक
# Will return all Springfields
query1 = firestore.col(collection_path).order("name").order("state").start_at("Springfield")

# Will return "Springfield, Missouri" and "Springfield, Wisconsin"
query2 = firestore.col(collection_path).order("name").order("state").start_at(["Springfield", "Missouri"])