ক্লাউড ফায়ার স্টোরে সাধারণ এবং যৌগিক ক্যোয়ারীগুলি সম্পাদন করুন

ক্লাউড ফায়ারস্টোর কোন কালেকশন বা কালেকশন গ্রুপ থেকে কোন ডকুমেন্টগুলো পুনরুদ্ধার করতে চান তা নির্দিষ্ট করার জন্য শক্তিশালী কোয়েরি ফাংশনালিটি প্রদান করে। এই প্রশ্নের মধ্যে কোন ব্যবহার করা যেতে পারে get() বা addSnapshotListener() , বর্ণনা অনুযায়ী ডেটা পান এবং রিয়েলটাইম আপডেট পান

উদাহরণ ডেটা

শুরু করার জন্য, শহরগুলি সম্পর্কে কিছু তথ্য লিখুন যাতে আমরা এটিকে আবার পড়ার বিভিন্ন উপায় দেখতে পারি:

ওয়েব সংস্করণ 9

import { collection, doc, setDoc } from "firebase/firestore"; 

const citiesRef = collection(db, "cities");

await setDoc(doc(citiesRef, "SF"), {
    name: "San Francisco", state: "CA", country: "USA",
    capital: false, population: 860000,
    regions: ["west_coast", "norcal"] });
await setDoc(doc(citiesRef, "LA"), {
    name: "Los Angeles", state: "CA", country: "USA",
    capital: false, population: 3900000,
    regions: ["west_coast", "socal"] });
await setDoc(doc(citiesRef, "DC"), {
    name: "Washington, D.C.", state: null, country: "USA",
    capital: true, population: 680000,
    regions: ["east_coast"] });
await setDoc(doc(citiesRef, "TOK"), {
    name: "Tokyo", state: null, country: "Japan",
    capital: true, population: 9000000,
    regions: ["kanto", "honshu"] });
await setDoc(doc(citiesRef, "BJ"), {
    name: "Beijing", state: null, country: "China",
    capital: true, population: 21500000,
    regions: ["jingjinji", "hebei"] });

ওয়েব সংস্করণ 8

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

citiesRef.doc("SF").set({
    name: "San Francisco", state: "CA", country: "USA",
    capital: false, population: 860000,
    regions: ["west_coast", "norcal"] });
citiesRef.doc("LA").set({
    name: "Los Angeles", state: "CA", country: "USA",
    capital: false, population: 3900000,
    regions: ["west_coast", "socal"] });
citiesRef.doc("DC").set({
    name: "Washington, D.C.", state: null, country: "USA",
    capital: true, population: 680000,
    regions: ["east_coast"] });
citiesRef.doc("TOK").set({
    name: "Tokyo", state: null, country: "Japan",
    capital: true, population: 9000000,
    regions: ["kanto", "honshu"] });
citiesRef.doc("BJ").set({
    name: "Beijing", state: null, country: "China",
    capital: true, population: 21500000,
    regions: ["jingjinji", "hebei"] });
সুইফট
let citiesRef = db.collection("cities")

citiesRef.document("SF").setData([
    "name": "San Francisco",
    "state": "CA",
    "country": "USA",
    "capital": false,
    "population": 860000,
    "regions": ["west_coast", "norcal"]
    ])
citiesRef.document("LA").setData([
    "name": "Los Angeles",
    "state": "CA",
    "country": "USA",
    "capital": false,
    "population": 3900000,
    "regions": ["west_coast", "socal"]
    ])
citiesRef.document("DC").setData([
    "name": "Washington D.C.",
    "country": "USA",
    "capital": true,
    "population": 680000,
    "regions": ["east_coast"]
    ])
citiesRef.document("TOK").setData([
    "name": "Tokyo",
    "country": "Japan",
    "capital": true,
    "population": 9000000,
    "regions": ["kanto", "honshu"]
    ])
citiesRef.document("BJ").setData([
    "name": "Beijing",
    "country": "China",
    "capital": true,
    "population": 21500000,
    "regions": ["jingjinji", "hebei"]
    ])
উদ্দেশ্য গ
FIRCollectionReference *citiesRef = [self.db collectionWithPath:@"cities"];
[[citiesRef documentWithPath:@"SF"] setData:@{
  @"name": @"San Francisco",
  @"state": @"CA",
  @"country": @"USA",
  @"capital": @(NO),
  @"population": @860000,
  @"regions": @[@"west_coast", @"norcal"]
}];
[[citiesRef documentWithPath:@"LA"] setData:@{
  @"name": @"Los Angeles",
  @"state": @"CA",
  @"country": @"USA",
  @"capital": @(NO),
  @"population": @3900000,
  @"regions": @[@"west_coast", @"socal"]
}];
[[citiesRef documentWithPath:@"DC"] setData:@{
  @"name": @"Washington D.C.",
  @"country": @"USA",
  @"capital": @(YES),
  @"population": @680000,
  @"regions": @[@"east_coast"]
}];
[[citiesRef documentWithPath:@"TOK"] setData:@{
  @"name": @"Tokyo",
  @"country": @"Japan",
  @"capital": @(YES),
  @"population": @9000000,
  @"regions": @[@"kanto", @"honshu"]
}];
[[citiesRef documentWithPath:@"BJ"] setData:@{
  @"name": @"Beijing",
  @"country": @"China",
  @"capital": @(YES),
  @"population": @21500000,
  @"regions": @[@"jingjinji", @"hebei"]
}];

জাভা

CollectionReference cities = db.collection("cities");

Map<String, Object> data1 = new HashMap<>();
data1.put("name", "San Francisco");
data1.put("state", "CA");
data1.put("country", "USA");
data1.put("capital", false);
data1.put("population", 860000);
data1.put("regions", Arrays.asList("west_coast", "norcal"));
cities.document("SF").set(data1);

Map<String, Object> data2 = new HashMap<>();
data2.put("name", "Los Angeles");
data2.put("state", "CA");
data2.put("country", "USA");
data2.put("capital", false);
data2.put("population", 3900000);
data2.put("regions", Arrays.asList("west_coast", "socal"));
cities.document("LA").set(data2);

Map<String, Object> data3 = new HashMap<>();
data3.put("name", "Washington D.C.");
data3.put("state", null);
data3.put("country", "USA");
data3.put("capital", true);
data3.put("population", 680000);
data3.put("regions", Arrays.asList("east_coast"));
cities.document("DC").set(data3);

Map<String, Object> data4 = new HashMap<>();
data4.put("name", "Tokyo");
data4.put("state", null);
data4.put("country", "Japan");
data4.put("capital", true);
data4.put("population", 9000000);
data4.put("regions", Arrays.asList("kanto", "honshu"));
cities.document("TOK").set(data4);

Map<String, Object> data5 = new HashMap<>();
data5.put("name", "Beijing");
data5.put("state", null);
data5.put("country", "China");
data5.put("capital", true);
data5.put("population", 21500000);
data5.put("regions", Arrays.asList("jingjinji", "hebei"));
cities.document("BJ").set(data5);

কোটলিন+কেটিএক্স

val cities = db.collection("cities")

val data1 = hashMapOf(
        "name" to "San Francisco",
        "state" to "CA",
        "country" to "USA",
        "capital" to false,
        "population" to 860000,
        "regions" to listOf("west_coast", "norcal")
)
cities.document("SF").set(data1)

val data2 = hashMapOf(
        "name" to "Los Angeles",
        "state" to "CA",
        "country" to "USA",
        "capital" to false,
        "population" to 3900000,
        "regions" to listOf("west_coast", "socal")
)
cities.document("LA").set(data2)

val data3 = hashMapOf(
        "name" to "Washington D.C.",
        "state" to null,
        "country" to "USA",
        "capital" to true,
        "population" to 680000,
        "regions" to listOf("east_coast")
)
cities.document("DC").set(data3)

val data4 = hashMapOf(
        "name" to "Tokyo",
        "state" to null,
        "country" to "Japan",
        "capital" to true,
        "population" to 9000000,
        "regions" to listOf("kanto", "honshu")
)
cities.document("TOK").set(data4)

val data5 = hashMapOf(
        "name" to "Beijing",
        "state" to null,
        "country" to "China",
        "capital" to true,
        "population" to 21500000,
        "regions" to listOf("jingjinji", "hebei")
)
cities.document("BJ").set(data5)
জাভা
CollectionReference cities = db.collection("cities");
List<ApiFuture<WriteResult>> futures = new ArrayList<>();
futures.add(
    cities
        .document("SF")
        .set(
            new City(
                "San Francisco",
                "CA",
                "USA",
                false,
                860000L,
                Arrays.asList("west_coast", "norcal"))));
futures.add(
    cities
        .document("LA")
        .set(
            new City(
                "Los Angeles",
                "CA",
                "USA",
                false,
                3900000L,
                Arrays.asList("west_coast", "socal"))));
futures.add(
    cities
        .document("DC")
        .set(
            new City(
                "Washington D.C.", null, "USA", true, 680000L, Arrays.asList("east_coast"))));
futures.add(
    cities
        .document("TOK")
        .set(
            new City(
                "Tokyo", null, "Japan", true, 9000000L, Arrays.asList("kanto", "honshu"))));
futures.add(
    cities
        .document("BJ")
        .set(
            new City(
                "Beijing",
                null,
                "China",
                true,
                21500000L,
                Arrays.asList("jingjinji", "hebei"))));
// (optional) block on documents successfully added
ApiFutures.allAsList(futures).get();
পাইথন
class City(object):
    def __init__(self, name, state, country, capital=False, population=0,
                 regions=[]):
        self.name = name
        self.state = state
        self.country = country
        self.capital = capital
        self.population = population
        self.regions = regions

    @staticmethod
    def from_dict(source):
        # ...

    def to_dict(self):
        # ...

    def __repr__(self):
        return(
            f'City(\
                name={self.name}, \
                country={self.country}, \
                population={self.population}, \
                capital={self.capital}, \
                regions={self.regions}\
            )'
        )
cities_ref = db.collection(u'cities')
cities_ref.document(u'BJ').set(
    City(u'Beijing', None, u'China', True, 21500000, [u'hebei']).to_dict())
cities_ref.document(u'SF').set(
    City(u'San Francisco', u'CA', u'USA', False, 860000,
         [u'west_coast', u'norcal']).to_dict())
cities_ref.document(u'LA').set(
    City(u'Los Angeles', u'CA', u'USA', False, 3900000,
         [u'west_coast', u'socal']).to_dict())
cities_ref.document(u'DC').set(
    City(u'Washington D.C.', None, u'USA', True, 680000,
         [u'east_coast']).to_dict())
cities_ref.document(u'TOK').set(
    City(u'Tokyo', None, u'Japan', True, 9000000,
         [u'kanto', u'honshu']).to_dict())

পাইথন

class City(object):
    def __init__(self, name, state, country, capital=False, population=0, regions=[]):
        self.name = name
        self.state = state
        self.country = country
        self.capital = capital
        self.population = population
        self.regions = regions

    @staticmethod
    def from_dict(source):
        # ...

    def to_dict(self):
        # ...

    def __repr__(self):
        return f"City(\
                name={self.name}, \
                country={self.country}, \
                population={self.population}, \
                capital={self.capital}, \
                regions={self.regions}\
            )"
cities_ref = db.collection("cities")
await cities_ref.document("BJ").set(
    City("Beijing", None, "China", True, 21500000, ["hebei"]).to_dict()
)
await cities_ref.document("SF").set(
    City(
        "San Francisco", "CA", "USA", False, 860000, ["west_coast", "norcal"]
    ).to_dict()
)
await cities_ref.document("LA").set(
    City(
        "Los Angeles", "CA", "USA", False, 3900000, ["west_coast", "socal"]
    ).to_dict()
)
await cities_ref.document("DC").set(
    City("Washington D.C.", None, "USA", True, 680000, ["east_coast"]).to_dict()
)
await cities_ref.document("TOK").set(
    City("Tokyo", None, "Japan", True, 9000000, ["kanto", "honshu"]).to_dict()
)
সি ++
CollectionReference cities = db->Collection("cities");

cities.Document("SF").Set({
    {"name", FieldValue::String("San Francisco")},
    {"state", FieldValue::String("CA")},
    {"country", FieldValue::String("USA")},
    {"capital", FieldValue::Boolean(false)},
    {"population", FieldValue::Integer(860000)},
    {"regions", FieldValue::Array({FieldValue::String("west_coast"),
                                   FieldValue::String("norcal")})},
});

cities.Document("LA").Set({
    {"name", FieldValue::String("Los Angeles")},
    {"state", FieldValue::String("CA")},
    {"country", FieldValue::String("USA")},
    {"capital", FieldValue::Boolean(false)},
    {"population", FieldValue::Integer(3900000)},
    {"regions", FieldValue::Array({FieldValue::String("west_coast"),
                                   FieldValue::String("socal")})},
});

cities.Document("DC").Set({
    {"name", FieldValue::String("Washington D.C.")},
    {"state", FieldValue::Null()},
    {"country", FieldValue::String("USA")},
    {"capital", FieldValue::Boolean(true)},
    {"population", FieldValue::Integer(680000)},
    {"regions",
     FieldValue::Array({FieldValue::String("east_coast")})},
});

cities.Document("TOK").Set({
    {"name", FieldValue::String("Tokyo")},
    {"state", FieldValue::Null()},
    {"country", FieldValue::String("Japan")},
    {"capital", FieldValue::Boolean(true)},
    {"population", FieldValue::Integer(9000000)},
    {"regions", FieldValue::Array({FieldValue::String("kanto"),
                                   FieldValue::String("honshu")})},
});

cities.Document("BJ").Set({
    {"name", FieldValue::String("Beijing")},
    {"state", FieldValue::Null()},
    {"country", FieldValue::String("China")},
    {"capital", FieldValue::Boolean(true)},
    {"population", FieldValue::Integer(21500000)},
    {"regions", FieldValue::Array({FieldValue::String("jingjinji"),
                                   FieldValue::String("hebei")})},
});
Node.js
const citiesRef = db.collection('cities');

await citiesRef.doc('SF').set({
  name: 'San Francisco', state: 'CA', country: 'USA',
  capital: false, population: 860000,
  regions: ['west_coast', 'norcal']
});
await citiesRef.doc('LA').set({
  name: 'Los Angeles', state: 'CA', country: 'USA',
  capital: false, population: 3900000,
  regions: ['west_coast', 'socal']
});
await citiesRef.doc('DC').set({
  name: 'Washington, D.C.', state: null, country: 'USA',
  capital: true, population: 680000,
  regions: ['east_coast']
});
await citiesRef.doc('TOK').set({
  name: 'Tokyo', state: null, country: 'Japan',
  capital: true, population: 9000000,
  regions: ['kanto', 'honshu']
});
await citiesRef.doc('BJ').set({
  name: 'Beijing', state: null, country: 'China',
  capital: true, population: 21500000,
  regions: ['jingjinji', 'hebei']
});
যাওয়া
cities := []struct {
	id string
	c  City
}{
	{
		id: "SF",
		c: City{Name: "San Francisco", State: "CA", Country: "USA",
			Capital: false, Population: 860000,
			Regions: []string{"west_coast", "norcal"}},
	},
	{
		id: "LA",
		c: City{Name: "Los Angeles", State: "CA", Country: "USA",
			Capital: false, Population: 3900000,
			Regions: []string{"west_coast", "socal"}},
	},
	{
		id: "DC",
		c: City{Name: "Washington D.C.", Country: "USA",
			Capital: true, Population: 680000,
			Regions: []string{"east_coast"}},
	},
	{
		id: "TOK",
		c: City{Name: "Tokyo", Country: "Japan",
			Capital: true, Population: 9000000,
			Regions: []string{"kanto", "honshu"}},
	},
	{
		id: "BJ",
		c: City{Name: "Beijing", Country: "China",
			Capital: true, Population: 21500000,
			Regions: []string{"jingjinji", "hebei"}},
	},
}
for _, c := range cities {
	if _, err := client.Collection("cities").Doc(c.id).Set(ctx, c.c); err != nil {
		return err
	}
}
পিএইচপি
$citiesRef = $db->collection('samples/php/cities');
$citiesRef->document('SF')->set([
    'name' => 'San Francisco',
    'state' => 'CA',
    'country' => 'USA',
    'capital' => false,
    'population' => 860000,
    'regions' => ['west_coast', 'norcal']
]);
$citiesRef->document('LA')->set([
    'name' => 'Los Angeles',
    'state' => 'CA',
    'country' => 'USA',
    'capital' => false,
    'population' => 3900000,
    'regions' => ['west_coast', 'socal']
]);
$citiesRef->document('DC')->set([
    'name' => 'Washington D.C.',
    'state' => null,
    'country' => 'USA',
    'capital' => true,
    'population' => 680000,
    'regions' => ['east_coast']
]);
$citiesRef->document('TOK')->set([
    'name' => 'Tokyo',
    'state' => null,
    'country' => 'Japan',
    'capital' => true,
    'population' => 9000000,
    'regions' => ['kanto', 'honshu']
]);
$citiesRef->document('BJ')->set([
    'name' => 'Beijing',
    'state' => null,
    'country' => 'China',
    'capital' => true,
    'population' => 21500000,
    'regions' => ['jingjinji', 'hebei']
]);
printf('Added example cities data to the cities collection.' . PHP_EOL);
Unক্য
CollectionReference citiesRef = db.Collection("cities");
citiesRef.Document("SF").SetAsync(new Dictionary<string, object>(){
    { "Name", "San Francisco" },
    { "State", "CA" },
    { "Country", "USA" },
    { "Capital", false },
    { "Population", 860000 },
    { "Regions", new ArrayList{"west_coast", "norcal"} }
});
citiesRef.Document("LA").SetAsync(new Dictionary<string, object>(){
    { "Name", "Los Angeles" },
    { "State", "CA" },
    { "Country", "USA" },
    { "Capital", false },
    { "Population", 3900000 },
    { "Regions", new ArrayList{"west_coast", "socal"} }
});
citiesRef.Document("DC").SetAsync(new Dictionary<string, object>(){
    { "Name", "Washington D.C." },
    { "State", null },
    { "Country", "USA" },
    { "Capital", true },
    { "Population", 680000 },
    { "Regions", new ArrayList{"east_coast"} }
});
citiesRef.Document("TOK").SetAsync(new Dictionary<string, object>(){
    { "Name", "Tokyo" },
    { "State", null },
    { "Country", "Japan" },
    { "Capital", true },
    { "Population", 9000000 },
    { "Regions", new ArrayList{"kanto", "honshu"} }
});
citiesRef.Document("BJ").SetAsync(new Dictionary<string, object>(){
    { "Name", "Beijing" },
    { "State", null },
    { "Country", "China" },
    { "Capital", true },
    { "Population", 21500000 },
    { "Regions", new ArrayList{"jingjinji", "hebei"} }
});
সি#
CollectionReference citiesRef = db.Collection("cities");
await citiesRef.Document("SF").SetAsync(new Dictionary<string, object>(){
    { "Name", "San Francisco" },
    { "State", "CA" },
    { "Country", "USA" },
    { "Capital", false },
    { "Population", 860000 },
    { "Regions", new ArrayList{"west_coast", "norcal"} }
});
await citiesRef.Document("LA").SetAsync(new Dictionary<string, object>(){
    { "Name", "Los Angeles" },
    { "State", "CA" },
    { "Country", "USA" },
    { "Capital", false },
    { "Population", 3900000 },
    { "Regions", new ArrayList{"west_coast", "socal"} }
});
await citiesRef.Document("DC").SetAsync(new Dictionary<string, object>(){
    { "Name", "Washington D.C." },
    { "State", null },
    { "Country", "USA" },
    { "Capital", true },
    { "Population", 680000 },
    { "Regions", new ArrayList{"east_coast"} }
});
await citiesRef.Document("TOK").SetAsync(new Dictionary<string, object>(){
    { "Name", "Tokyo" },
    { "State", null },
    { "Country", "Japan" },
    { "Capital", true },
    { "Population", 9000000 },
    { "Regions", new ArrayList{"kanto", "honshu"} }
});
await citiesRef.Document("BJ").SetAsync(new Dictionary<string, object>(){
    { "Name", "Beijing" },
    { "State", null },
    { "Country", "China" },
    { "Capital", true },
    { "Population", 21500000 },
    { "Regions", new ArrayList{"jingjinji", "hebei"} }
});
Console.WriteLine("Added example cities data to the cities collection.");
রুবি
cities_ref = firestore.col collection_path
cities_ref.doc("SF").set(
  {
    name:       "San Francisco",
    state:      "CA",
    country:    "USA",
    capital:    false,
    population: 860_000,
    regions:    ["west_coast", "norcal"]
  }
)
cities_ref.doc("LA").set(
  {
    name:       "Los Angeles",
    state:      "CA",
    country:    "USA",
    capital:    false,
    population: 3_900_000,
    regions:    ["west_coast", "socal"]
  }
)
cities_ref.doc("DC").set(
  {
    name:       "Washington D.C.",
    state:      nil,
    country:    "USA",
    capital:    true,
    population: 680_000,
    regions:    ["east_coast"]
  }
)
cities_ref.doc("TOK").set(
  {
    name:       "Tokyo",
    state:      nil,
    country:    "Japan",
    capital:    true,
    population: 9_000_000,
    regions:    ["kanto", "honshu"]
  }
)
cities_ref.doc("BJ").set(
  {
    name:       "Beijing",
    state:      nil,
    country:    "China",
    capital:    true,
    population: 21_500_000,
    regions:    ["jingjinji", "hebei"]
  }
)

সহজ প্রশ্ন

নিম্নলিখিত প্রশ্নের সাথে ফেরৎ রাষ্ট্রের সঙ্গে সমস্ত শহর CA :

ওয়েব সংস্করণ 9

// Create a reference to the cities collection
import { collection, query, where } from "firebase/firestore";
const citiesRef = collection(db, "cities");

// Create a query against the collection.
const q = query(citiesRef, where("state", "==", "CA"));

ওয়েব সংস্করণ 8

// Create a reference to the cities collection
var citiesRef = db.collection("cities");

// Create a query against the collection.
var query = citiesRef.where("state", "==", "CA");
সুইফট
// Create a reference to the cities collection
let citiesRef = db.collection("cities")

// Create a query against the collection.
let query = citiesRef.whereField("state", isEqualTo: "CA")
উদ্দেশ্য গ
// Create a reference to the cities collection
FIRCollectionReference *citiesRef = [self.db collectionWithPath:@"cities"];
// Create a query against the collection.
FIRQuery *query = [citiesRef queryWhereField:@"state" isEqualTo:@"CA"];

জাভা

// Create a reference to the cities collection
CollectionReference citiesRef = db.collection("cities");

// Create a query against the collection.
Query query = citiesRef.whereEqualTo("state", "CA");

কোটলিন+কেটিএক্স

// Create a reference to the cities collection
val citiesRef = db.collection("cities")

// Create a query against the collection.
val query = citiesRef.whereEqualTo("state", "CA")
জাভা
// Create a reference to the cities collection
CollectionReference cities = db.collection("cities");
// Create a query against the collection.
Query query = cities.whereEqualTo("state", "CA");
// retrieve  query results asynchronously using query.get()
ApiFuture<QuerySnapshot> querySnapshot = query.get();

for (DocumentSnapshot document : querySnapshot.get().getDocuments()) {
  System.out.println(document.getId());
}
পাইথন
# Create a reference to the cities collection
cities_ref = db.collection(u'cities')

# Create a query against the collection
query_ref = cities_ref.where(u'state', u'==', u'CA')

পাইথন

# Create a reference to the cities collection
cities_ref = db.collection("cities")

# Create a query against the collection
query_ref = cities_ref.where("state", "==", "CA")
সি ++
CollectionReference cities_ref = db->Collection("cities");
// Create a query against the collection.
Query query_ca =
    cities_ref.WhereEqualTo("state", FieldValue::String("CA"));
Node.js
// Create a reference to the cities collection
const citiesRef = db.collection('cities');

// Create a query against the collection
const queryRef = citiesRef.where('state', '==', 'CA');
যাওয়া
query := client.Collection("cities").Where("state", "==", "CA")
পিএইচপি
$citiesRef = $db->collection('samples/php/cities');
$query = $citiesRef->where('state', '=', 'CA');
$snapshot = $query->documents();
foreach ($snapshot as $document) {
    printf('Document %s returned by query state=CA' . PHP_EOL, $document->id());
}
Unক্য
CollectionReference citiesRef = db.Collection("cities");
Query query = citiesRef.WhereEqualTo("State", "CA");
query.GetSnapshotAsync().ContinueWithOnMainThread((querySnapshotTask) =>
{
    foreach (DocumentSnapshot documentSnapshot in querySnapshotTask.Result.Documents)
    {
        Debug.Log(String.Format("Document {0} returned by query State=CA", documentSnapshot.Id));
    } 
});
সি#
CollectionReference citiesRef = db.Collection("cities");
Query query = citiesRef.WhereEqualTo("State", "CA");
QuerySnapshot querySnapshot = await query.GetSnapshotAsync();
foreach (DocumentSnapshot documentSnapshot in querySnapshot.Documents)
{
    Console.WriteLine("Document {0} returned by query State=CA", documentSnapshot.Id);
}
রুবি
cities_ref = firestore.col collection_path

query = cities_ref.where "state", "=", "CA"

query.get do |city|
  puts "Document #{city.document_id} returned by query state=CA."
end

নিম্নলিখিত প্রশ্নটি সমস্ত রাজধানী শহরগুলি ফেরত দেয়:

ওয়েব সংস্করণ 9

import { collection, query, where } from "firebase/firestore";
const citiesRef = collection(db, "cities");

const q = query(citiesRef, where("capital", "==", true));

ওয়েব সংস্করণ 8

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

var query = citiesRef.where("capital", "==", true);
সুইফট
let capitalCities = db.collection("cities").whereField("capital", isEqualTo: true)
উদ্দেশ্য গ
FIRQuery *capitalCities =
    [[self.db collectionWithPath:@"cities"] queryWhereField:@"capital" isEqualTo:@YES];

জাভা

Query capitalCities = db.collection("cities").whereEqualTo("capital", true);

কোটলিন+কেটিএক্স

val capitalCities = db.collection("cities").whereEqualTo("capital", true)
জাভা
// Create a reference to the cities collection
CollectionReference cities = db.collection("cities");
// Create a query against the collection.
Query query = cities.whereEqualTo("capital", true);
// retrieve  query results asynchronously using query.get()
ApiFuture<QuerySnapshot> querySnapshot = query.get();

for (DocumentSnapshot document : querySnapshot.get().getDocuments()) {
  System.out.println(document.getId());
}
পাইথন
cities_ref = db.collection(u'cities')

query = cities_ref.where(u'capital', u'==', True)

পাইথন

cities_ref = db.collection("cities")

query = cities_ref.where("capital", "==", True)
সি ++
Query capital_cities = db->Collection("cities").WhereEqualTo(
    "capital", FieldValue::Boolean(true));
Node.js
// Create a reference to the cities collection
const citiesRef = db.collection('cities');

// Create a query against the collection
const allCapitalsRes = await citiesRef.where('capital', '==', true).get();
যাওয়া
query := client.Collection("cities").Where("capital", "==", true)
পিএইচপি
$citiesRef = $db->collection('samples/php/cities');
$query = $citiesRef->where('capital', '=', true);
$snapshot = $query->documents();
foreach ($snapshot as $document) {
    printf('Document %s returned by query capital=true' . PHP_EOL, $document->id());
}
Unক্য
CollectionReference citiesRef = db.Collection("cities");
Query query = citiesRef.WhereEqualTo("Capital", true);
query.GetSnapshotAsync().ContinueWithOnMainThread((querySnapshotTask) =>
{
    foreach (DocumentSnapshot documentSnapshot in querySnapshotTask.Result.Documents)
    {
        Debug.Log(String.Format("Document {0} returned by query Capital=true", documentSnapshot.Id));
    } 
});
সি#
CollectionReference citiesRef = db.Collection("cities");
Query query = citiesRef.WhereEqualTo("Capital", true);
QuerySnapshot querySnapshot = await query.GetSnapshotAsync();
foreach (DocumentSnapshot documentSnapshot in querySnapshot.Documents)
{
    Console.WriteLine("Document {0} returned by query Capital=true", documentSnapshot.Id);
}
রুবি
cities_ref = firestore.col collection_path

query = cities_ref.where "capital", "=", true

query.get do |city|
  puts "Document #{city.document_id} returned by query capital=true."
end

একটি প্রশ্ন চালান

একটি ক্যোয়ারী বস্তুর তৈরি হয়ে গেলে ব্যবহার get() ফলাফল পুনরুদ্ধার করতে ফাংশন:

ওয়েব সংস্করণ 9

import { collection, query, where, getDocs } from "firebase/firestore";

const q = query(collection(db, "cities"), where("capital", "==", true));

const querySnapshot = await getDocs(q);
querySnapshot.forEach((doc) => {
  // doc.data() is never undefined for query doc snapshots
  console.log(doc.id, " => ", doc.data());
});

ওয়েব সংস্করণ 8

db.collection("cities").where("capital", "==", true)
    .get()
    .then((querySnapshot) => {
        querySnapshot.forEach((doc) => {
            // doc.data() is never undefined for query doc snapshots
            console.log(doc.id, " => ", doc.data());
        });
    })
    .catch((error) => {
        console.log("Error getting documents: ", error);
    });
সুইফট
db.collection("cities").whereField("capital", isEqualTo: true)
    .getDocuments() { (querySnapshot, err) in
        if let err = err {
            print("Error getting documents: \(err)")
        } else {
            for document in querySnapshot!.documents {
                print("\(document.documentID) => \(document.data())")
            }
        }
}
উদ্দেশ্য গ
[[[self.db collectionWithPath:@"cities"] queryWhereField:@"capital" isEqualTo:@(YES)]
    getDocumentsWithCompletion:^(FIRQuerySnapshot *snapshot, NSError *error) {
      if (error != nil) {
        NSLog(@"Error getting documents: %@", error);
      } else {
        for (FIRDocumentSnapshot *document in snapshot.documents) {
          NSLog(@"%@ => %@", document.documentID, document.data);
        }
      }
    }];

জাভা

db.collection("cities")
        .whereEqualTo("capital", true)
        .get()
        .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
            @Override
            public void onComplete(@NonNull Task<QuerySnapshot> task) {
                if (task.isSuccessful()) {
                    for (QueryDocumentSnapshot document : task.getResult()) {
                        Log.d(TAG, document.getId() + " => " + document.getData());
                    }
                } else {
                    Log.d(TAG, "Error getting documents: ", task.getException());
                }
            }
        });

কোটলিন+কেটিএক্স

db.collection("cities")
        .whereEqualTo("capital", true)
        .get()
        .addOnSuccessListener { documents ->
            for (document in documents) {
                Log.d(TAG, "${document.id} => ${document.data}")
            }
        }
        .addOnFailureListener { exception ->
            Log.w(TAG, "Error getting documents: ", exception)
        }
জাভা
//asynchronously retrieve multiple documents
ApiFuture<QuerySnapshot> future =
    db.collection("cities").whereEqualTo("capital", true).get();
// future.get() blocks on response
List<QueryDocumentSnapshot> documents = future.get().getDocuments();
for (DocumentSnapshot document : documents) {
  System.out.println(document.getId() + " => " + document.toObject(City.class));
}
পাইথন
# Note: Use of CollectionRef stream() is prefered to get()
docs = db.collection(u'cities').where(u'capital', u'==', True).stream()

for doc in docs:
    print(f'{doc.id} => {doc.to_dict()}')

পাইথন

# Note: Use of CollectionRef stream() is prefered to get()
docs = db.collection("cities").where("capital", "==", True).stream()

async for doc in docs:
    print(f"{doc.id} => {doc.to_dict()}")
সি ++
db->Collection("cities")
    .WhereEqualTo("capital", FieldValue::Boolean(true))
    .Get()
    .OnCompletion([](const Future<QuerySnapshot>& future) {
      if (future.error() == Error::kErrorOk) {
        for (const DocumentSnapshot& document :
             future.result()->documents()) {
          std::cout << document << '\n';
        }
      } else {
        std::cout << "Error getting documents: " << future.error_message()
                  << '\n';
      }
    });
Node.js
const citiesRef = db.collection('cities');
const snapshot = await citiesRef.where('capital', '==', true).get();
if (snapshot.empty) {
  console.log('No matching documents.');
  return;
}  

snapshot.forEach(doc => {
  console.log(doc.id, '=>', doc.data());
});
যাওয়া
fmt.Println("All capital cities:")
iter := client.Collection("cities").Where("capital", "==", true).Documents(ctx)
for {
	doc, err := iter.Next()
	if err == iterator.Done {
		break
	}
	if err != nil {
		return err
	}
	fmt.Println(doc.Data())
}
পিএইচপি
$citiesRef = $db->collection('samples/php/cities');
$query = $citiesRef->where('capital', '=', true);
$documents = $query->documents();
foreach ($documents as $document) {
    if ($document->exists()) {
        printf('Document data for document %s:' . PHP_EOL, $document->id());
        print_r($document->data());
        printf(PHP_EOL);
    } else {
        printf('Document %s does not exist!' . PHP_EOL, $document->id());
    }
}
Unক্য
Query capitalQuery = db.Collection("cities").WhereEqualTo("Capital", true);
capitalQuery.GetSnapshotAsync().ContinueWithOnMainThread(task => {
  QuerySnapshot capitalQuerySnapshot = task.Result;
  foreach (DocumentSnapshot documentSnapshot in capitalQuerySnapshot.Documents) {
    Debug.Log(String.Format("Document data for {0} document:", documentSnapshot.Id));
    Dictionary<string, object> city = documentSnapshot.ToDictionary();
    foreach (KeyValuePair<string, object> pair in city) {
      Debug.Log(String.Format("{0}: {1}", pair.Key, pair.Value));
    }

    // Newline to separate entries
    Debug.Log("");
  };
});
সি#
Query capitalQuery = db.Collection("cities").WhereEqualTo("Capital", true);
QuerySnapshot capitalQuerySnapshot = await capitalQuery.GetSnapshotAsync();
foreach (DocumentSnapshot documentSnapshot in capitalQuerySnapshot.Documents)
{
    Console.WriteLine("Document data for {0} document:", documentSnapshot.Id);
    Dictionary<string, object> city = documentSnapshot.ToDictionary();
    foreach (KeyValuePair<string, object> pair in city)
    {
        Console.WriteLine("{0}: {1}", pair.Key, pair.Value);
    }
    Console.WriteLine("");
}
রুবি
cities_ref = firestore.col collection_path

query = cities_ref.where "capital", "=", true

query.get do |city|
  puts "#{city.document_id} data: #{city.data}."
end

দেখুন ডেটা পান ক্যোয়ারী ফলাফল পুনরুদ্ধারের উপর আরও তথ্যের জন্য। আপনি এটিও করতে পারেন একটি শ্রোতা যোগ বর্তমান ফলাফল পেতে এবং ভবিষ্যতের আপডেট দেখার জন্য শুনতে এক প্রশ্নের।

অপারেটরদের জিজ্ঞাসা করুন

where() একটি ক্ষেত্র উপর ফিল্টার করতে, একটি তুলনামূলক অপারেটর, এবং একটি মান: পদ্ধতি তিনটি প্যারামিটার নেয়। ক্লাউড ফায়ারস্টোর নিম্নলিখিত তুলনা অপারেটরগুলিকে সমর্থন করে:

উদাহরণ স্বরূপ:

ওয়েব সংস্করণ 9

const stateQuery = query(citiesRef, where("state", "==", "CA"));
const populationQuery = query(citiesRef, where("population", "<", 100000));
const nameQuery = query(citiesRef, where("name", ">=", "San Francisco"));

ওয়েব সংস্করণ 8

const stateQuery = citiesRef.where("state", "==", "CA");
const populationQuery = citiesRef.where("population", "<", 100000);
const nameQuery = citiesRef.where("name", ">=", "San Francisco");
সুইফট
let stateQuery = citiesRef.whereField("state", isEqualTo: "CA")
let populationQuery = citiesRef.whereField("population", isLessThan: 100000)
let nameQuery = citiesRef.whereField("name", isGreaterThanOrEqualTo: "San Francisco")
উদ্দেশ্য গ
FIRQuery *stateQuery = [citiesRef queryWhereField:@"state" isEqualTo:@"CA"];
FIRQuery *populationQuery = [citiesRef queryWhereField:@"population" isLessThan:@100000];
FIRQuery *nameQuery = [citiesRef queryWhereField:@"name" isGreaterThanOrEqualTo:@"San Francisco"];

জাভা

Query stateQuery = citiesRef.whereEqualTo("state", "CA");
Query populationQuery = citiesRef.whereLessThan("population", 100000);
Query nameQuery = citiesRef.whereGreaterThanOrEqualTo("name", "San Francisco");

কোটলিন+কেটিএক্স

val stateQuery = citiesRef.whereEqualTo("state", "CA")
val populationQuery = citiesRef.whereLessThan("population", 100000)
val nameQuery = citiesRef.whereGreaterThanOrEqualTo("name", "San Francisco")
জাভা
Query stateQuery = cities.whereEqualTo("state", "CA");
Query populationQuery = cities.whereLessThan("population", 1000000L);
Query nameQuery = cities.whereGreaterThanOrEqualTo("name", "San Francisco");
পাইথন
cities_ref = db.collection(u'cities')

cities_ref.where(u'state', u'==', u'CA')
cities_ref.where(u'population', u'<', 1000000)
cities_ref.where(u'name', u'>=', u'San Francisco')

পাইথন

cities_ref = db.collection("cities")

cities_ref.where("state", "==", "CA")
cities_ref.where("population", "<", 1000000)
cities_ref.where("name", ">=", "San Francisco")
সি ++
cities_ref.WhereEqualTo("state", FieldValue::String("CA"));
cities_ref.WhereLessThan("population", FieldValue::Integer(100000));
cities_ref.WhereGreaterThanOrEqualTo("name",
                                     FieldValue::String("San Francisco"));
Node.js
const stateQueryRes = await citiesRef.where('state', '==', 'CA').get();
const populationQueryRes = await citiesRef.where('population', '<', 1000000).get();
const nameQueryRes = await citiesRef.where('name', '>=', 'San Francisco').get();
যাওয়া
countryQuery := cities.Where("state", "==", "CA")
popQuery := cities.Where("population", "<", 1000000)
cityQuery := cities.Where("name", ">=", "San Francisco")
পিএইচপি
$stateQuery = $citiesRef->where('state', '=', 'CA');
$populationQuery = $citiesRef->where('population', '>', 1000000);
$nameQuery = $citiesRef->where('name', '>=', 'San Francisco');
Unক্য
Query stateQuery = citiesRef.WhereEqualTo("State", "CA");
Query populationQuery = citiesRef.WhereGreaterThan("Population", 1000000);
Query nameQuery = citiesRef.WhereGreaterThanOrEqualTo("Name", "San Francisco");
সি#
Query stateQuery = citiesRef.WhereEqualTo("State", "CA");
Query populationQuery = citiesRef.WhereGreaterThan("Population", 1000000);
Query nameQuery = citiesRef.WhereGreaterThanOrEqualTo("Name", "San Francisco");
রুবি
state_query      = cities_ref.where "state", "=", "CA"
population_query = cities_ref.where "population", ">", 1_000_000
name_query       = cities_ref.where "name", ">=", "San Francisco"

সমান নয় ( != )

সমান নয় (ব্যবহার != ) অপারেটর নথি যেখানে দেওয়া ক্ষেত্র বিদ্যমান এবং তুলনা মান মেলে না দেখাবে। উদাহরণ স্বরূপ:

ওয়েব
citiesRef.where("capital", "!=", false);
সুইফট
let notEqualQuery = citiesRef.whereField("capital", isNotEqualTo: false)
উদ্দেশ্য গ
query = [citiesRef queryWhereField:@"capital" isNotEqualTo:@NO];

জাভা

Query notCapitalQuery = citiesRef.whereNotEqualTo("capital", false);

কোটলিন+কেটিএক্স

val notCapitalQuery = citiesRef.whereNotEqualTo("capital", false)
জাভা
CollectionReference citiesRef = db.collection("cities");

Query query = citiesRef.whereNotEqualTo("capital", false);
পাইথন
// Snippet not yet available
সি ++
// Snippet not yet available
Node.js
const capitalNotFalseRes = await citiesRef.where('capital', '!=', false).get();
যাওয়া
// Snippet not yet available
পিএইচপি
// Snippet not yet available
Unক্য
// Snippet not yet available
সি#
// Snippet not yet available
রুবি
cities_ref = firestore.col collection_path
query = cities_ref.where "capital", "!=", false

এই প্রশ্নের সাথে যে ফেরৎ city নথির যেখানে capital ক্ষেত্র ভিন্ন অন্য কোনো মান বিদ্যমান false বা null । এর মধ্যে রয়েছে city কাগজপত্র যেখানে capital ক্ষেত্রের মান সমান true বা ব্যতীত কোনো অ-বুলিয়ান মান null

এই প্রশ্নের সাথে ফেরত দেয় না city কাগজপত্র যেখানে capital ক্ষেত্র বিদ্যমান নেই। না সমান ( != ) এবং not-in প্রশ্নের নথি যেখানে দেওয়া ক্ষেত্র বিদ্যমান নয় অগ্রাহ্য।

একটি ক্ষেত্র যখন এটি কোন মানে সেট এর একটি খালি স্ট্রিং (তত্সহ, বিদ্যমান "" ), null , এবং NaN (একটি নম্বর)। লক্ষ্য করুন null ক্ষেত্র মান মেলে না != ক্লজ, কারণ x != null মূল্যায়ণ undefined

সীমাবদ্ধতা

জন্য দ্রষ্টব্য নিম্নলিখিত সীমাবদ্ধতা != প্রশ্নের:

  • শুধুমাত্র ডকুমেন্ট যেখানে প্রদত্ত ক্ষেত্রটি বিদ্যমান তা প্রশ্নের সাথে মেলে।
  • আপনি একত্রিত করতে পারবেন not-in এবং != একটি যৌগ ক্যোয়ারীতে।
  • একটি যৌগ ক্যোয়ারীতে, পরিসর ( < , <= , > , >= ) এবং সমান ( != , not-in ) তুলনা অবশ্যই একই মাঠে সব ফিল্টার।

অ্যারে সদস্যপদ

আপনি ব্যবহার করতে পারেন array-contains অ্যারের মান উপর ভিত্তি করে ফিল্টার অপারেটর। উদাহরণ স্বরূপ:

ওয়েব সংস্করণ 9

import { query, where } from "firebase/firestore";  
const q = query(citiesRef, where("regions", "array-contains", "west_coast"));

ওয়েব সংস্করণ 8

citiesRef.where("regions", "array-contains", "west_coast");
সুইফট
citiesRef
  .whereField("regions", arrayContains: "west_coast")
উদ্দেশ্য গ
[citiesRef queryWhereField:@"state" arrayContains:@"west_coast"];

জাভা

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

citiesRef.whereArrayContains("regions", "west_coast");

কোটলিন+কেটিএক্স

val citiesRef = db.collection("cities")

citiesRef.whereArrayContains("regions", "west_coast")
জাভা
CollectionReference citiesRef = db.collection("cities");
Query westCoastQuery = citiesRef.whereArrayContains("regions", "west_coast");
পাইথন
cities_ref = db.collection(u'cities')

query = cities_ref.where(u'regions', u'array_contains', u'west_coast')

পাইথন

cities_ref = db.collection("cities")

query = cities_ref.where("regions", "array_contains", "west_coast")
সি ++
// This is not yet supported.
Node.js
const westCoastCities = citiesRef.where('regions', 'array-contains',
  'west_coast').get();
যাওয়া
query := cities.Where("regions", "array-contains", "west_coast").Documents(ctx)
পিএইচপি
$containsQuery = $citiesRef->where('regions', 'array-contains', 'west_coast');
Unক্য
CollectionReference citiesRef = db.Collection("cities");
Query arrayContainsQuery = citiesRef.WhereArrayContains("region", "west_coast");
সি#
Query query = citiesRef.WhereArrayContains("Regions", "west_coast");
রুবি
cities_ref = firestore.col collection_path
cities = cities_ref.where "regions", "array-contains", "west_coast"

এই প্রশ্নের সাথে যে ফেরৎ city নথির যেখানে regions যদি ক্ষেত্রের একটি অ্যারের রয়েছে west_coast । যদি অ্যারেটিতে আপনি যে মানটি জিজ্ঞাসা করেন তার একাধিক দৃষ্টান্ত থাকে, নথিটি শুধুমাত্র একবার ফলাফলগুলিতে অন্তর্ভুক্ত করা হয়।

আপনি ব্যবহার করতে পারেন সর্বাধিক এক array-contains ক্যোয়ারী প্রতি দফা। আপনি একত্রিত করতে পারবেন না array-contains সঙ্গে array-contains-any

in , not-in , এবং array-contains-any

ব্যবহার করুন in 10 সমতা করার জন্য (একত্রিত অপারেটর == একটি লজিক্যাল সঙ্গে একই ক্ষেত্রের উপর) ক্লজ OR । একটি in ক্যোয়ারী আয় নথি যেখানে দেওয়া ক্ষেত্র তুলনা মূল্যবোধের কোনো সাথে মেলে। উদাহরণ স্বরূপ:

ওয়েব
citiesRef.where('country', 'in', ['USA', 'Japan']);
সুইফট
let citiesRef = db.collection("cities")

citiesRef.whereField("country", in: ["USA", "Japan"])
উদ্দেশ্য গ
FIRCollectionReference *citiesRef = [self.db collectionWithPath:@"cities"];

[citiesRef queryWhereField:@"country" in:@[@"USA", @"Japan"]];

জাভা

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

citiesRef.whereIn("country", Arrays.asList("USA", "Japan"));

কোটলিন+কেটিএক্স

val citiesRef = db.collection("cities")

citiesRef.whereIn("country", listOf("USA", "Japan"))
জাভা
CollectionReference citiesRef = db.collection("cities");

Query query = citiesRef.whereIn("country", Arrays.asList("USA", "Japan"));
পাইথন
cities_ref = db.collection(u'cities')

query = cities_ref.where(u'country', u'in', [u'USA', u'Japan'])
return query

পাইথন

cities_ref = db.collection("cities")

query = cities_ref.where("country", "in", ["USA", "Japan"])
return query
সি ++
// This is not yet supported.
Node.js
const usaOrJapan = await citiesRef.where('country', 'in', ['USA', 'Japan']).get();
যাওয়া
cities := client.Collection("cities")
query := cities.Where("country", "in", []string{"USA", "Japan"}).Documents(ctx)
পিএইচপি
// Snippet not yet available
Unক্য
CollectionReference citiesRef = db.Collection("cities");
List countriesList = new List<object>() {"USA", "Japan"};

Query whereInQuery = citiesRef.WhereIn("country", countriesList);
সি#
Query query = citiesRef.WhereIn("Country", new[] { "USA", "Japan" });
রুবি
cities_ref = firestore.col collection_path
usr_or_japan = cities_ref.where "country", "in", ["USA", "Japan"]

এই প্রশ্নের সাথে যে ফেরৎ city নথির যেখানে country ক্ষেত্র সেট করা হয় USA বা Japan । উদাহরণস্বরূপ তথ্য থেকে, এই অন্তর্ভুক্ত SF , LA , DC , এবং TOK নথি।

not-in

ব্যবহার করুন not-in অপারেটর 10 সমান নয় (আপনি একত্রিত করতে != ) ক্লজ একই ক্ষেত্রের উপর একটি লজিক্যাল সঙ্গে AND । একজন not-in ক্যোয়ারী আয় নথি যেখানে দেওয়া ক্ষেত্র, বিদ্যমান নয় null , এবং তুলনা মূল্যবোধের কোনো সাথে মেলে না। উদাহরণ স্বরূপ:

ওয়েব
citiesRef.where('country', 'not-in', ['USA', 'Japan']);
সুইফট
citiesRef.whereField("country", notIn: ["USA", "Japan"])
উদ্দেশ্য গ
[citiesRef queryWhereField:@"country" notIn:@[@"USA", @"Japan"]];

জাভা

citiesRef.whereNotIn("country", Arrays.asList("USA", "Japan"));

কোটলিন+কেটিএক্স

citiesRef.whereNotIn("country", listOf("USA", "Japan"))
জাভা
CollectionReference citiesRef = db.collection("cities");

Query query = citiesRef.whereNotIn("country", Arrays.asList("USA", "Japan"));
পাইথন
// Snippet not yet available
সি ++
// Snippet not yet available
Node.js
const notUsaOrJapan = await citiesRef.where('country', 'not-in', ['USA', 'Japan']).get();
যাওয়া
// Snippet not yet available
পিএইচপি
// Snippet not yet available
Unক্য
// Snippet not yet available
সি#
// Snippet not yet available
রুবি
cities_ref = firestore.col collection_path
usr_or_japan = cities_ref.where "country", "not_in", ["USA", "Japan"]

এই প্রশ্নের সাথে যে ফেরৎ city নথির যেখানে country ক্ষেত্র বিদ্যমান এবং সেট করা নেই USA , Japan , অথবা null । উদাহরণস্বরূপ তথ্য থেকে, এই অন্তর্ভুক্ত London এবং Hong Kong নথি।

not-in প্রশ্নের নথি যেখানে দেওয়া ক্ষেত্র বিদ্যমান নয় অগ্রাহ্য। একটি ক্ষেত্র যখন এটি কোন মানে সেট এর একটি খালি স্ট্রিং (তত্সহ, বিদ্যমান "" ), null , এবং NaN (একটি নম্বর)। লক্ষ্য করুন x != null মূল্যায়ণ undefined । একজন not-in সঙ্গে ক্যোয়ারী null তুলনা মান এক কোনো দস্তাবেজের সাথে মেলে না হিসাবে।

array-contains-any

ব্যবহার করুন array-contains-any 10 আপ একত্রিত অপারেটর array-contains একটি লজিক্যাল সঙ্গে একই মাঠে ক্লজ OR । একটি array-contains-any কোয়েরি ফেরৎ নথি যেখানে দেওয়া ক্ষেত্র একটি অ্যারের এক বা তুলনা মূল্যবোধের আরো রয়েছে:

ওয়েব
citiesRef.where('regions', 'array-contains-any',
    ['west_coast', 'east_coast']);
সুইফট
let citiesRef = db.collection("cities")
citiesRef.whereField("regions", arrayContainsAny: ["west_coast", "east_coast"])
উদ্দেশ্য গ
FIRCollectionReference *citiesRef = [self.db collectionWithPath:@"cities"];

[citiesRef queryWhereField:@"regions" arrayContainsAny:@[@"west_coast", @"east_coast"]];

জাভা

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

citiesRef.whereArrayContainsAny("regions", Arrays.asList("west_coast", "east_coast"));

কোটলিন+কেটিএক্স

val citiesRef = db.collection("cities")

citiesRef.whereArrayContainsAny("regions", listOf("west_coast", "east_coast"))
জাভা
CollectionReference citiesRef = db.collection("cities");

Query query =
    citiesRef.whereArrayContainsAny("regions", Arrays.asList("west_coast", "east_coast"));
পাইথন
cities_ref = db.collection(u'cities')

query = cities_ref.where(
    u'regions', u'array_contains_any', [u'west_coast', u'east_coast']
)
return query

পাইথন

cities_ref = db.collection("cities")

query = cities_ref.where(
    "regions", "array_contains_any", ["west_coast", "east_coast"]
)
return query
সি ++
// This is not yet supported.
Node.js
const coastalCities = await citiesRef.where('regions', 'array-contains-any',
    ['west_coast', 'east_coast']).get();
যাওয়া
cities := client.Collection("cities")
query := cities.Where("regions", "array-contains-any", []string{"west_coast", "east_coast"}).Documents(ctx)
পিএইচপি
// Snippet not yet available
Unক্য
CollectionReference citiesRef = db.Collection("cities");
List regionsList = new List<object>() {"west_coast", "east_coast"};

Query arrayContainsAnyQuery = citiesRef.WhereArrayContainsAny("regions", regionsList);
সি#
Query query = citiesRef.WhereArrayContainsAny("Regions", new[] { "west_coast", "east_coast" });
রুবি
cities_ref = firestore.col collection_path
costal_cities = cities_ref.where "regions", "array-contains-any", ["west_coast", "east_coast"]

এই প্রশ্নের সাথে প্রতিটি শহরে নথির যেখানে ফেরৎ region ক্ষেত্র একটি অ্যারের যে রয়েছে west_coast বা east_coast । উদাহরণস্বরূপ তথ্য থেকে, এই অন্তর্ভুক্ত SF , LA , এবং DC নথি।

এর থেকে ফলাফল array-contains-any ডি duped হয়। এমনকি যদি কোনো ডকুমেন্টের অ্যারে ক্ষেত্র তুলনামূলক মানগুলির একাধিকটির সাথে মেলে, ফলাফল সেটে সেই ডকুমেন্টটি শুধুমাত্র একবার অন্তর্ভুক্ত থাকে।

array-contains-any সবসময় অ্যারের ডাটা টাইপ দ্বারা ফিল্টার করে। উদাহরণ হিসেবে বলা যায়, ক্যোয়ারী উপরে একটি শহর নথির যেখানে একটি অ্যারের পরিবর্তে, ফিরে আসতে পারবেন না region ক্ষেত্র স্ট্রিং west_coast

আপনার জন্য একটি তুলনা মান হিসাবে একটি অ্যারের মান ব্যবহার করতে পারেন in কিন্তু অসদৃশ array-contains-any , এরে দৈর্ঘ্য, অর্ডার, এবং মূল্যবোধের একটি সঠিক ম্যাচ দফা ম্যাচ। উদাহরণ স্বরূপ:

ওয়েব
citiesRef.where('region', 'in',
    [['west_coast', 'east_coast']]);
সুইফট
citiesRef.whereField("regions", in: [["west_coast"], ["east_coast"]]);
উদ্দেশ্য গ
[citiesRef queryWhereField:@"regions" in:@[@[@"west_coast"], @[@"east_coast"]]];

জাভা

citiesRef.whereIn("regions", Arrays.asList(new String[]{"west_coast"}, new String[]{"east_coast"}));

কোটলিন+কেটিএক্স

citiesRef.whereIn("regions", listOf(arrayOf("west_coast"), arrayOf("east_coast")))
জাভা
CollectionReference citiesRef = db.collection("cities");

Query query =
    citiesRef.whereIn(
        "regions", Arrays.asList(Arrays.asList("west_coast"), Arrays.asList("east_coast")));
পাইথন
cities_ref = db.collection(u'cities')

query = cities_ref.where(
    u'regions', u'in', [[u'west_coast'], [u'east_coast']]
)
return query

পাইথন

cities_ref = db.collection("cities")

query = cities_ref.where("regions", "in", [["west_coast"], ["east_coast"]])
return query
সি ++
// This is not yet supported.
Node.js
const exactlyOneCoast = await citiesRef.where('region', 'in',
    [['west_coast', 'east_coast']]).get();
যাওয়া
cities := client.Collection("cities")
query := cities.Where("regions", "in", [][]string{{"west_coast"}, {"east_coast"}}).Documents(ctx)
পিএইচপি
// Snippet not yet available
Unক্য
// Not yet supported in the Unity SDK
সি#
Query query = citiesRef.WhereIn("Regions",
    new[] { new[] { "west_coast" }, new[] { "east_coast" } });
রুবি
cities_ref = firestore.col collection_path
exactly_one_cost = cities_ref.where "regions", "in", [["west_coast"], ["east_coast"]]

এই প্রশ্নের সাথে প্রতিটি শহরে ডকুমেন্ট ফেরৎ যেখানে region ক্ষেত্র একটি অ্যারের যে হয় ঠিক এক উপাদান রয়েছে west_coast বা east_coast । উদাহরণস্বরূপ ডেটা, শুধুমাত্র থেকে DC তার সাথে দস্তাবেজ যোগ্যতা region ক্ষেত্রে ["east_coast"]SF ডকুমেন্ট অবশ্য মিলছে না কারণ এটির region ক্ষেত্র ["west_coast", "norcal"]

সীমাবদ্ধতা

উল্লেখ্য জন্য নিম্নলিখিত সীমাবদ্ধতা in , not-in , এবং array-contains-any :

  • in , not-in , এবং array-contains-any সমর্থন 10 তুলনা মান।
  • আপনি ব্যবহার করতে পারেন সর্বাধিক এক array-contains ক্যোয়ারী প্রতি দফা। আপনি একত্রিত করতে পারবেন না array-contains সঙ্গে array-contains-any
  • আপনি সবচেয়ে এক ব্যবহার করতে পারেন in , not-in , অথবা array-contains-any কোয়েরি প্রতি দফা। আপনি একই ক্যোয়ারীতে এই অপারেটরগুলিকে একত্রিত করতে পারবেন না।
  • আপনি একত্রিত করতে পারবেন না not-in সঙ্গে সমান না !=
  • আপনি (একটি ক্ষেত্র একটি সমতা অন্তর্ভুক্ত দ্বারা আপনার প্রশ্নের অর্ডার করতে পারবেন না == ) অথবা in দফা।

যৌগিক প্রশ্ন

আপনি শৃঙ্খল একাধিক সমতা অপারেটার ( == বা array-contains ) পদ্ধতি আরো নির্দিষ্ট প্রশ্নের (লজিক্যাল তৈরি করতে AND )। যাইহোক, যদি আপনি একটি তৈরি করতে হবে যৌগিক সূচক বৈষম্য অপারেটরদের সঙ্গে সমতা অপারেটার একত্রিত করতে, < , <= , > , এবং !=

ওয়েব সংস্করণ 9

import { query, where } from "firebase/firestore";  

const q1 = query(citiesRef, where("state", "==", "CO"), where("name", "==", "Denver"));
const q2 = query(citiesRef, where("state", "==", "CA"), where("population", "<", 1000000));

ওয়েব সংস্করণ 8

const q1 = citiesRef.where("state", "==", "CO").where("name", "==", "Denver");
const q2 = citiesRef.where("state", "==", "CA").where("population", "<", 1000000);
সুইফট
citiesRef
    .whereField("state", isEqualTo: "CO")
    .whereField("name", isEqualTo: "Denver")
citiesRef
    .whereField("state", isEqualTo: "CA")
    .whereField("population", isLessThan: 1000000)
উদ্দেশ্য গ
[[citiesRef queryWhereField:@"state" isEqualTo:@"CO"]
    queryWhereField:@"name" isGreaterThanOrEqualTo:@"Denver"];
[[citiesRef queryWhereField:@"state" isEqualTo:@"CA"]
    queryWhereField:@"population" isLessThan:@1000000];

জাভা

citiesRef.whereEqualTo("state", "CO").whereEqualTo("name", "Denver");
citiesRef.whereEqualTo("state", "CA").whereLessThan("population", 1000000);

কোটলিন+কেটিএক্স

citiesRef.whereEqualTo("state", "CO").whereEqualTo("name", "Denver")
citiesRef.whereEqualTo("state", "CA").whereLessThan("population", 1000000)
জাভা
Query chainedQuery1 = cities.whereEqualTo("state", "CO").whereEqualTo("name", "Denver");
পাইথন
cities_ref = db.collection(u'cities')

denver_query = cities_ref.where(
    u'state', u'==', u'CO').where(u'name', u'==', u'Denver')
large_us_cities_query = cities_ref.where(
    u'state', u'==', u'CA').where(u'population', u'>', 1000000)

পাইথন

cities_ref = db.collection("cities")

denver_query = cities_ref.where("state", "==", "CO").where("name", "==", "Denver")
large_us_cities_query = cities_ref.where("state", "==", "CA").where(
    "population", ">", 1000000
)
সি ++
cities_ref.WhereEqualTo("state", FieldValue::String("CO"))
    .WhereEqualTo("name", FieldValue::String("Denver"));
cities_ref.WhereEqualTo("state", FieldValue::String("CA"))
    .WhereLessThan("population", FieldValue::Integer(1000000));
Node.js
citiesRef.where('state', '==', 'CO').where('name', '==', 'Denver');
citiesRef.where('state', '==', 'CA').where('population', '<', 1000000);
যাওয়া
denverQuery := cities.Where("name", "==", "Denver").Where("state", "==", "CO")
caliQuery := cities.Where("state", "==", "CA").Where("population", "<=", 1000000)
query := cities.Where("country", "==", "USA").Where("population", ">", 5000000)
পিএইচপি
$chainedQuery = $citiesRef
    ->where('state', '=', 'CA')
    ->where('name', '=', 'San Francisco');
Unক্য
Query chainedQuery = citiesRef
    .WhereEqualTo("State", "CA")
    .WhereEqualTo("Name", "San Francisco");
সি#
Query chainedQuery = citiesRef
    .WhereEqualTo("State", "CA")
    .WhereEqualTo("Name", "San Francisco");
রুবি
chained_query = cities_ref.where("state", "=", "CA").where("name", "=", "San Francisco")

আপনি পরিসীমা সম্পাদন করতে পারবেন ( < , <= , > , >= ) অথবা না সমান ( != শুধুমাত্র একটি একক ক্ষেত্রের উপর তুলনা), এবং আপনি সর্বাধিক এক অন্তর্ভুক্ত করতে পারে array-contains বা array-contains-any একটি যৌগ ক্যোয়ারীতে দফা :

বৈধ: শুধুমাত্র এক ক্ষেত্রের উপর বিন্যাস ফিল্টার

ওয়েব সংস্করণ 9

import { query, where } from "firebase/firestore";  

const q1 = query(citiesRef, where("state", ">=", "CA"), where("state", "<=", "IN"));
const q2 = query(citiesRef, where("state", "==", "CA"), where("population", ">", 1000000));

ওয়েব সংস্করণ 8

const q1 = citiesRef.where("state", ">=", "CA").where("state", "<=", "IN");
const q2 = citiesRef.where("state", "==", "CA").where("population", ">", 1000000);
সুইফট
citiesRef
    .whereField("state", isGreaterThanOrEqualTo: "CA")
    .whereField("state", isLessThanOrEqualTo: "IN")
citiesRef
    .whereField("state", isEqualTo: "CA")
    .whereField("population", isGreaterThan: 1000000)
উদ্দেশ্য গ
[[citiesRef queryWhereField:@"state" isGreaterThanOrEqualTo:@"CA"]
    queryWhereField:@"state" isLessThanOrEqualTo:@"IN"];
[[citiesRef queryWhereField:@"state" isEqualTo:@"CA"]
    queryWhereField:@"population" isGreaterThan:@1000000];

জাভা

citiesRef.whereGreaterThanOrEqualTo("state", "CA")
        .whereLessThanOrEqualTo("state", "IN");
citiesRef.whereEqualTo("state", "CA")
        .whereGreaterThan("population", 1000000);

কোটলিন+কেটিএক্স

citiesRef.whereGreaterThanOrEqualTo("state", "CA")
        .whereLessThanOrEqualTo("state", "IN")
citiesRef.whereEqualTo("state", "CA")
        .whereGreaterThan("population", 1000000)
জাভা
Query validQuery1 =
    cities.whereGreaterThanOrEqualTo("state", "CA").whereLessThanOrEqualTo("state", "IN");
Query validQuery2 = cities.whereEqualTo("state", "CA").whereGreaterThan("population", 1000000);
পাইথন
cities_ref = db.collection(u'cities')
cities_ref.where(u'state', u'>=', u'CA').where(u'state', u'<=', u'IN')

পাইথন

cities_ref = db.collection("cities")
cities_ref.where("state", ">=", "CA").where("state", "<=", "IN")
সি ++
cities_ref.WhereGreaterThanOrEqualTo("state", FieldValue::String("CA"))
    .WhereLessThanOrEqualTo("state", FieldValue::String("IN"));
cities_ref.WhereEqualTo("state", FieldValue::String("CA"))
    .WhereGreaterThan("population", FieldValue::Integer(1000000));
Node.js
citiesRef.where('state', '>=', 'CA').where('state', '<=', 'IN');
citiesRef.where('state', '==', 'CA').where('population', '>', 1000000);
যাওয়া
stateQuery := cities.Where("state", ">=", "CA").Where("state", "<", "IN")
populationQuery := cities.Where("state", "==", "CA").Where("population", ">", 1000000)
পিএইচপি
$rangeQuery = $citiesRef
    ->where('state', '>=', 'CA')
    ->where('state', '<=', 'IN');
Unক্য
Query rangeQuery = citiesRef
    .WhereGreaterThanOrEqualTo("State", "CA")
    .WhereLessThanOrEqualTo("State", "IN");
সি#
Query rangeQuery = citiesRef
    .WhereGreaterThanOrEqualTo("State", "CA")
    .WhereLessThanOrEqualTo("State", "IN");
রুবি
range_query = cities_ref.where("state", ">=", "CA").where("state", "<=", "IN")

অবৈধ: বিন্যাস বিভিন্ন ক্ষেত্রে উপর ফিল্টার

ওয়েব সংস্করণ 9

import { query, where } from "firebase/firestore";  

const q = query(citiesRef, where("state", ">=", "CA"), where("population", ">", 100000));

ওয়েব সংস্করণ 8

citiesRef.where("state", ">=", "CA").where("population", ">", 100000);
সুইফট
citiesRef
    .whereField("state", isGreaterThanOrEqualTo: "CA")
    .whereField("population", isGreaterThan: 1000000)
উদ্দেশ্য গ
[[citiesRef queryWhereField:@"state" isGreaterThanOrEqualTo:@"CA"]
    queryWhereField:@"population" isGreaterThan:@1000000];

জাভা

citiesRef.whereGreaterThanOrEqualTo("state", "CA").whereGreaterThan("population", 100000);

কোটলিন+কেটিএক্স

citiesRef.whereGreaterThanOrEqualTo("state", "CA")
        .whereGreaterThan("population", 100000)
জাভা
Query invalidRangeQuery =
    cities.whereGreaterThanOrEqualTo("state", "CA").whereGreaterThan("population", 100000);
পাইথন
cities_ref = db.collection(u'cities')
cities_ref.where(
    u'state', u'>=', u'CA').where(u'population', u'>=', 1000000)

পাইথন

cities_ref = db.collection("cities")
cities_ref.where("state", ">=", "CA").where("population", ">=", 1000000)
সি ++
// BAD EXAMPLE -- will crash the program:
cities_ref.WhereGreaterThanOrEqualTo("state", FieldValue::String("CA"))
    .WhereGreaterThan("population", FieldValue::Integer(100000));
Node.js
citiesRef.where('state', '>=', 'CA').where('population', '>', 1000000);
যাওয়া
query := cities.Where("state", ">=", "CA").Where("population", ">", 1000000)
পিএইচপি
$invalidRangeQuery = $citiesRef
    ->where('state', '>=', 'CA')
    ->where('population', '>', 1000000);
Unক্য
Query invalidRangeQuery = citiesRef
    .WhereGreaterThanOrEqualTo("State", "CA")
    .WhereGreaterThan("Population", 1000000);
সি#
Query invalidRangeQuery = citiesRef
    .WhereGreaterThanOrEqualTo("State", "CA")
    .WhereGreaterThan("Population", 1000000);
রুবি
invalid_range_query = cities_ref.where("state", ">=", "CA").where("population", ">", 1_000_000)

সংগ্রহ গ্রুপের প্রশ্ন

একটি সংগ্রহ গোষ্ঠী একই আইডি সহ সমস্ত সংগ্রহ নিয়ে গঠিত। ডিফল্টরূপে, প্রশ্নগুলি আপনার ডাটাবেসের একক সংগ্রহ থেকে ফলাফল পুনরুদ্ধার করে। একটি সংগ্রহ গোষ্ঠীর পরিবর্তে একটি সংগ্রহ গোষ্ঠী থেকে নথি পুনরুদ্ধার করতে একটি সংগ্রহ গোষ্ঠী ক্যোয়ারী ব্যবহার করুন।

উদাহরণস্বরূপ, যদি আপনি একটি তৈরি করতে পারেন landmarks প্রতিটি শহরে একটি দর্শনীয় স্থান subcollection যোগ করে সংগ্রহ গ্রুপ:

ওয়েব
var citiesRef = db.collection('cities');

var landmarks = Promise.all([
    citiesRef.doc('SF').collection('landmarks').doc().set({
        name: 'Golden Gate Bridge',
        type: 'bridge'
    }),
    citiesRef.doc('SF').collection('landmarks').doc().set({
        name: 'Legion of Honor',
        type: 'museum'
    }),
    citiesRef.doc('LA').collection('landmarks').doc().set({
        name: 'Griffith Park',
        type: 'park'
    }),
    citiesRef.doc('LA').collection('landmarks').doc().set({
        name: 'The Getty',
        type: 'museum'
    }),
    citiesRef.doc('DC').collection('landmarks').doc().set({
        name: 'Lincoln Memorial',
        type: 'memorial'
    }),
    citiesRef.doc('DC').collection('landmarks').doc().set({
        name: 'National Air and Space Museum',
        type: 'museum'
    }),
    citiesRef.doc('TOK').collection('landmarks').doc().set({
        name: 'Ueno Park',
        type: 'park'
    }),
    citiesRef.doc('TOK').collection('landmarks').doc().set({
        name: 'National Museum of Nature and Science',
        type: 'museum'
    }),
    citiesRef.doc('BJ').collection('landmarks').doc().set({
        name: 'Jingshan Park',
        type: 'park'
    }),
    citiesRef.doc('BJ').collection('landmarks').doc().set({
        name: 'Beijing Ancient Observatory',
        type: 'museum'
    })
]);
সুইফট
let citiesRef = db.collection("cities")

var data = ["name": "Golden Gate Bridge", "type": "bridge"]
citiesRef.document("SF").collection("landmarks").addDocument(data: data)

data = ["name": "Legion of Honor", "type": "museum"]
citiesRef.document("SF").collection("landmarks").addDocument(data: data)

data = ["name": "Griffith Park", "type": "park"]
citiesRef.document("LA").collection("landmarks").addDocument(data: data)

data = ["name": "The Getty", "type": "museum"]
citiesRef.document("LA").collection("landmarks").addDocument(data: data)

data = ["name": "Lincoln Memorial", "type": "memorial"]
citiesRef.document("DC").collection("landmarks").addDocument(data: data)

data = ["name": "National Air and Space Museum", "type": "museum"]
citiesRef.document("DC").collection("landmarks").addDocument(data: data)

data = ["name": "Ueno Park", "type": "park"]
citiesRef.document("TOK").collection("landmarks").addDocument(data: data)

data = ["name": "National Museum of Nature and Science", "type": "museum"]
citiesRef.document("TOK").collection("landmarks").addDocument(data: data)

data = ["name": "Jingshan Park", "type": "park"]
citiesRef.document("BJ").collection("landmarks").addDocument(data: data)

data = ["name": "Beijing Ancient Observatory", "type": "museum"]
citiesRef.document("BJ").collection("landmarks").addDocument(data: data)
উদ্দেশ্য গ
FIRCollectionReference *citiesRef = [self.db collectionWithPath:@"cities"];

NSDictionary *data = @{@"name": @"Golden Gate Bridge", @"type": @"bridge"};
[[[citiesRef documentWithPath:@"SF"] collectionWithPath:@"landmarks"] addDocumentWithData:data];

data = @{@"name": @"Legion of Honor", @"type": @"museum"};
[[[citiesRef documentWithPath:@"SF"] collectionWithPath:@"landmarks"] addDocumentWithData:data];

data = @{@"name": @"Griffith Park", @"type": @"park"};
[[[citiesRef documentWithPath:@"LA"] collectionWithPath:@"landmarks"] addDocumentWithData:data];

data = @{@"name": @"The Getty", @"type": @"museum"};
[[[citiesRef documentWithPath:@"LA"] collectionWithPath:@"landmarks"] addDocumentWithData:data];

data = @{@"name": @"Lincoln Memorial", @"type": @"memorial"};
[[[citiesRef documentWithPath:@"DC"] collectionWithPath:@"landmarks"] addDocumentWithData:data];

data = @{@"name": @"National Air and Space Museum", @"type": @"museum"};
[[[citiesRef documentWithPath:@"DC"] collectionWithPath:@"landmarks"] addDocumentWithData:data];

data = @{@"name": @"Ueno Park", @"type": @"park"};
[[[citiesRef documentWithPath:@"TOK"] collectionWithPath:@"landmarks"] addDocumentWithData:data];

data = @{@"name": @"National Museum of Nature and Science", @"type": @"museum"};
[[[citiesRef documentWithPath:@"TOK"] collectionWithPath:@"landmarks"] addDocumentWithData:data];

data = @{@"name": @"Jingshan Park", @"type": @"park"};
[[[citiesRef documentWithPath:@"BJ"] collectionWithPath:@"landmarks"] addDocumentWithData:data];

data = @{@"name": @"Beijing Ancient Observatory", @"type": @"museum"};
[[[citiesRef documentWithPath:@"BJ"] collectionWithPath:@"landmarks"] addDocumentWithData:data];

জাভা

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

Map<String, Object> ggbData = new HashMap<>();
ggbData.put("name", "Golden Gate Bridge");
ggbData.put("type", "bridge");
citiesRef.document("SF").collection("landmarks").add(ggbData);

Map<String, Object> lohData = new HashMap<>();
lohData.put("name", "Legion of Honor");
lohData.put("type", "museum");
citiesRef.document("SF").collection("landmarks").add(lohData);

Map<String, Object> gpData = new HashMap<>();
gpData.put("name", "Griffith Park");
gpData.put("type", "park");
citiesRef.document("LA").collection("landmarks").add(gpData);

Map<String, Object> tgData = new HashMap<>();
tgData.put("name", "The Getty");
tgData.put("type", "museum");
citiesRef.document("LA").collection("landmarks").add(tgData);

Map<String, Object> lmData = new HashMap<>();
lmData.put("name", "Lincoln Memorial");
lmData.put("type", "memorial");
citiesRef.document("DC").collection("landmarks").add(lmData);

Map<String, Object> nasaData = new HashMap<>();
nasaData.put("name", "National Air and Space Museum");
nasaData.put("type", "museum");
citiesRef.document("DC").collection("landmarks").add(nasaData);

Map<String, Object> upData = new HashMap<>();
upData.put("name", "Ueno Park");
upData.put("type", "park");
citiesRef.document("TOK").collection("landmarks").add(upData);

Map<String, Object> nmData = new HashMap<>();
nmData.put("name", "National Museum of Nature and Science");
nmData.put("type", "museum");
citiesRef.document("TOK").collection("landmarks").add(nmData);

Map<String, Object> jpData = new HashMap<>();
jpData.put("name", "Jingshan Park");
jpData.put("type", "park");
citiesRef.document("BJ").collection("landmarks").add(jpData);

Map<String, Object> baoData = new HashMap<>();
baoData.put("name", "Beijing Ancient Observatory");
baoData.put("type", "museum");
citiesRef.document("BJ").collection("landmarks").add(baoData);

কোটলিন+কেটিএক্স

val citiesRef = db.collection("cities")

val ggbData = mapOf(
        "name" to "Golden Gate Bridge",
        "type" to "bridge"
)
citiesRef.document("SF").collection("landmarks").add(ggbData)

val lohData = mapOf(
        "name" to "Legion of Honor",
        "type" to "museum"
)
citiesRef.document("SF").collection("landmarks").add(lohData)

val gpData = mapOf(
        "name" to "Griffth Park",
        "type" to "park"
)
citiesRef.document("LA").collection("landmarks").add(gpData)

val tgData = mapOf(
        "name" to "The Getty",
        "type" to "museum"
)
citiesRef.document("LA").collection("landmarks").add(tgData)

val lmData = mapOf(
        "name" to "Lincoln Memorial",
        "type" to "memorial"
)
citiesRef.document("DC").collection("landmarks").add(lmData)

val nasaData = mapOf(
        "name" to "National Air and Space Museum",
        "type" to "museum"
)
citiesRef.document("DC").collection("landmarks").add(nasaData)

val upData = mapOf(
        "name" to "Ueno Park",
        "type" to "park"
)
citiesRef.document("TOK").collection("landmarks").add(upData)

val nmData = mapOf(
        "name" to "National Musuem of Nature and Science",
        "type" to "museum"
)
citiesRef.document("TOK").collection("landmarks").add(nmData)

val jpData = mapOf(
        "name" to "Jingshan Park",
        "type" to "park"
)
citiesRef.document("BJ").collection("landmarks").add(jpData)

val baoData = mapOf(
        "name" to "Beijing Ancient Observatory",
        "type" to "musuem"
)
citiesRef.document("BJ").collection("landmarks").add(baoData)
জাভা
CollectionReference cities = db.collection("cities");

final List<ApiFuture<WriteResult>> futures =
    Arrays.asList(
        cities
            .document("SF")
            .collection("landmarks")
            .document()
            .set(
                new HashMap<String, String>() {
                  {
                    put("name", "Golden Gate Bridge");
                    put("type", "bridge");
                  }
                }),
        cities
            .document("SF")
            .collection("landmarks")
            .document()
            .set(
                new HashMap<String, String>() {
                  {
                    put("name", "Legion of Honor");
                    put("type", "museum");
                  }
                }),
        cities
            .document("LA")
            .collection("landmarks")
            .document()
            .set(
                new HashMap<String, String>() {
                  {
                    put("name", "Griffith Park");
                    put("type", "park");
                  }
                }),
        cities
            .document("LA")
            .collection("landmarks")
            .document()
            .set(
                new HashMap<String, String>() {
                  {
                    put("name", "The Getty");
                    put("type", "museum");
                  }
                }),
        cities
            .document("DC")
            .collection("landmarks")
            .document()
            .set(
                new HashMap<String, String>() {
                  {
                    put("name", "Lincoln Memorial");
                    put("type", "memorial");
                  }
                }),
        cities
            .document("DC")
            .collection("landmarks")
            .document()
            .set(
                new HashMap<String, String>() {
                  {
                    put("name", "National Air and Space Museum");
                    put("type", "museum");
                  }
                }),
        cities
            .document("TOK")
            .collection("landmarks")
            .document()
            .set(
                new HashMap<String, String>() {
                  {
                    put("name", "Ueno Park");
                    put("type", "park");
                  }
                }),
        cities
            .document("TOK")
            .collection("landmarks")
            .document()
            .set(
                new HashMap<String, String>() {
                  {
                    put("name", "National Museum of Nature and Science");
                    put("type", "museum");
                  }
                }),
        cities
            .document("BJ")
            .collection("landmarks")
            .document()
            .set(
                new HashMap<String, String>() {
                  {
                    put("name", "Jingshan Park");
                    put("type", "park");
                  }
                }),
        cities
            .document("BJ")
            .collection("landmarks")
            .document()
            .set(
                new HashMap<String, String>() {
                  {
                    put("name", "Beijing Ancient Observatory");
                    put("type", "museum");
                  }
                }));
final List<WriteResult> landmarks = ApiFutures.allAsList(futures).get();
পাইথন
cities = db.collection(u'cities')

sf_landmarks = cities.document(u'SF').collection(u'landmarks')
sf_landmarks.document().set({
    u'name': u'Golden Gate Bridge',
    u'type': u'bridge'
})
sf_landmarks.document().set({
    u'name': u'Legion of Honor',
    u'type': u'museum'
})
la_landmarks = cities.document(u'LA').collection(u'landmarks')
la_landmarks.document().set({
    u'name': u'Griffith Park',
    u'type': u'park'
})
la_landmarks.document().set({
    u'name': u'The Getty',
    u'type': u'museum'
})
dc_landmarks = cities.document(u'DC').collection(u'landmarks')
dc_landmarks.document().set({
    u'name': u'Lincoln Memorial',
    u'type': u'memorial'
})
dc_landmarks.document().set({
    u'name': u'National Air and Space Museum',
    u'type': u'museum'
})
tok_landmarks = cities.document(u'TOK').collection(u'landmarks')
tok_landmarks.document().set({
    u'name': u'Ueno Park',
    u'type': u'park'
})
tok_landmarks.document().set({
    u'name': u'National Museum of Nature and Science',
    u'type': u'museum'
})
bj_landmarks = cities.document(u'BJ').collection(u'landmarks')
bj_landmarks.document().set({
    u'name': u'Jingshan Park',
    u'type': u'park'
})
bj_landmarks.document().set({
    u'name': u'Beijing Ancient Observatory',
    u'type': u'museum'
})

পাইথন

cities = db.collection("cities")

sf_landmarks = cities.document("SF").collection("landmarks")
await sf_landmarks.document().set({"name": "Golden Gate Bridge", "type": "bridge"})
await sf_landmarks.document().set({"name": "Legion of Honor", "type": "museum"})
la_landmarks = cities.document("LA").collection("landmarks")
await la_landmarks.document().set({"name": "Griffith Park", "type": "park"})
await la_landmarks.document().set({"name": "The Getty", "type": "museum"})
dc_landmarks = cities.document("DC").collection("landmarks")
await dc_landmarks.document().set({"name": "Lincoln Memorial", "type": "memorial"})
await dc_landmarks.document().set(
    {"name": "National Air and Space Museum", "type": "museum"}
)
tok_landmarks = cities.document("TOK").collection("landmarks")
await tok_landmarks.document().set({"name": "Ueno Park", "type": "park"})
await tok_landmarks.document().set(
    {"name": "National Museum of Nature and Science", "type": "museum"}
)
bj_landmarks = cities.document("BJ").collection("landmarks")
await bj_landmarks.document().set({"name": "Jingshan Park", "type": "park"})
await bj_landmarks.document().set(
    {"name": "Beijing Ancient Observatory", "type": "museum"}
)
সি ++
// This is not yet supported.
Node.js
const citiesRef = db.collection('cities');

await citiesRef.doc('SF').collection('landmarks').doc().set({
  name: 'Golden Gate Bridge',
  type: 'bridge'
});
await citiesRef.doc('SF').collection('landmarks').doc().set({
  name: 'Legion of Honor',
  type: 'museum'
});
await citiesRef.doc('LA').collection('landmarks').doc().set({
  name: 'Griffith Park',
  type: 'park'
});
await citiesRef.doc('LA').collection('landmarks').doc().set({
  name: 'The Getty',
  type: 'museum'
});
await citiesRef.doc('DC').collection('landmarks').doc().set({
  name: 'Lincoln Memorial',
  type: 'memorial'
});
await citiesRef.doc('DC').collection('landmarks').doc().set({
  name: 'National Air and Space Museum',
  type: 'museum'
});
await citiesRef.doc('TOK').collection('landmarks').doc().set({
  name: 'Ueno Park',
  type: 'park'
});
await citiesRef.doc('TOK').collection('landmarks').doc().set({
  name: 'National Museum of Nature and Science',
  type: 'museum'
});
await citiesRef.doc('BJ').collection('landmarks').doc().set({
  name: 'Jingshan Park',
  type: 'park'
});
await citiesRef.doc('BJ').collection('landmarks').doc().set({ 
  name: 'Beijing Ancient Observatory',
  type: 'museum'
});
যাওয়া
import (
	"context"
	"fmt"

	"cloud.google.com/go/firestore"
)

// collectionGroupSetup sets up a collection group to query.
func collectionGroupSetup(projectID, cityCollection string) error {
	ctx := context.Background()

	client, err := firestore.NewClient(ctx, projectID)
	if err != nil {
		return fmt.Errorf("firestore.NewClient: %v", err)
	}
	defer client.Close()

	landmarks := []struct {
		city, name, t string
	}{
		{"SF", "Golden Gate Bridge", "bridge"},
		{"SF", "Legion of Honor", "museum"},
		{"LA", "Griffith Park", "park"},
		{"LA", "The Getty", "museum"},
		{"DC", "Lincoln Memorial", "memorial"},
		{"DC", "National Air and Space Museum", "museum"},
		{"TOK", "Ueno Park", "park"},
		{"TOK", "National Museum of Nature and Science", "museum"},
		{"BJ", "Jingshan Park", "park"},
		{"BJ", "Beijing Ancient Observatory", "museum"},
	}

	cities := client.Collection(cityCollection)
	for _, l := range landmarks {
		if _, err := cities.Doc(l.city).Collection("landmarks").NewDoc().Set(ctx, map[string]string{
			"name": l.name,
			"type": l.t,
		}); err != nil {
			return fmt.Errorf("Set: %v", err)
		}
	}

	return nil
}
পিএইচপি
// Snippet not yet available
Unক্য
// Not yet supported in the Unity SDK
সি#
await citiesRef.Document("SF").Collection("landmarks").Document()
    .CreateAsync(new { Name = "Golden Gate Bridge", Type = "bridge" });
await citiesRef.Document("SF").Collection("landmarks").Document()
    .CreateAsync(new { Name = "Legion of Honor", Type = "museum" });
await citiesRef.Document("LA").Collection("landmarks").Document()
    .CreateAsync(new { Name = "Griffith Park", Type = "park" });
await citiesRef.Document("DC").Collection("landmarks").Document()
    .CreateAsync(new { Name = "Lincoln Memorial", Type = "memorial" });
await citiesRef.Document("DC").Collection("landmarks").Document()
    .CreateAsync(new { Name = "National Air And Space Museum", Type = "museum" });
await citiesRef.Document("TOK").Collection("landmarks").Document()
    .CreateAsync(new { Name = "Ueno Park", Type = "park" });
await citiesRef.Document("TOK").Collection("landmarks").Document()
    .CreateAsync(new { Name = "National Museum of Nature and Science", Type = "museum" });
await citiesRef.Document("BJ").Collection("landmarks").Document()
    .CreateAsync(new { Name = "Jingshan Park", Type = "park" });
await citiesRef.Document("BJ").Collection("landmarks").Document()
    .CreateAsync(new { Name = "Beijing Ancient Observatory", Type = "museum" });
রুবি
cities_ref = firestore.col collection_path

sf_landmarks = cities_ref.document("SF").collection("landmarks")
sf_landmarks.document.set(
  {
    name: "Golden Gate Bridge",
    type: "bridge"
  }
)
sf_landmarks.document.set(
  {
    name: "Legion of Honor",
    type: "museum"
  }
)

la_landmarks = cities_ref.document("LA").collection("landmarks")
la_landmarks.document.set(
  {
    name: "Griffith Park",
    type: "park"
  }
)
la_landmarks.document.set(
  {
    name: "The Getty",
    type: "museum"
  }
)

dc_landmarks = cities_ref.document("DC").collection("landmarks")
dc_landmarks.document.set(
  {
    name: "Lincoln Memorial",
    type: "memorial"
  }
)
dc_landmarks.document.set(
  {
    name: "National Air and Space Museum",
    type: "museum"
  }
)

tok_landmarks = cities_ref.document("TOK").collection("landmarks")
tok_landmarks.document.set(
  {
    name: "Ueno Park",
    type: "park"
  }
)
tok_landmarks.document.set(
  {
    name: "National Museum of Nature and Science",
    type: "museum"
  }
)

bj_landmarks = cities_ref.document("BJ").collection("landmarks")
bj_landmarks.document.set(
  {
    name: "Jingshan Park",
    type: "park"
  }
)
bj_landmarks.document.set(
  {
    name: "Beijing Ancient Observatory",
    type: "museum"
  }
)

আমরা সহজ এবং যৌগ ক্যোয়ারী বর্ণনা একটি একক শহরের ক্যোয়ারীতে আগে ব্যবহার করতে পারেন landmarks subcollection, কিন্তু আপনি যে শহরের থেকে ফলাফল পুনরুদ্ধার করতে চাইতে পারেন landmarks একবারে subcollection।

landmarks সংগ্রহে গ্রুপ আইডি দিয়ে সব সংগ্রহ নিয়ে গঠিত landmarks , এবং যদি আপনি একটি সংগ্রহে গ্রুপ ক্যোয়ারী ব্যবহার করে এটা খোঁজ করতে পারেন। উদাহরণস্বরূপ, এই সংগ্রহটি গ্রুপ ক্যোয়ারী সব আহরণ museum সমস্ত শহর জুড়ে চেনার:

ওয়েব
->
var museums = db.collectionGroup('landmarks').where('type', '==', 'museum');
museums.get().then((querySnapshot) => {
    querySnapshot.forEach((doc) => {
        console.log(doc.id, ' => ', doc.data());
    });
});
সুইফট
db.collectionGroup("landmarks").whereField("type", isEqualTo: "museum").getDocuments { (snapshot, error) in
    // ...
}
উদ্দেশ্য গ
[[[self.db collectionGroupWithID:@"landmarks"] queryWhereField:@"type" isEqualTo:@"museum"]
    getDocumentsWithCompletion:^(FIRQuerySnapshot *snapshot, NSError *error) {
    // ...
}];

জাভা

db.collectionGroup("landmarks").whereEqualTo("type", "museum").get()
        .addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
            @Override
            public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
                // ...
            }
        });

কোটলিন+কেটিএক্স

db.collectionGroup("landmarks").whereEqualTo("type", "museum").get()
        .addOnSuccessListener { queryDocumentSnapshots ->
            // ...
        }
জাভা
final Query museums = db.collectionGroup("landmarks").whereEqualTo("type", "museum");
final ApiFuture<QuerySnapshot> querySnapshot = museums.get();
for (DocumentSnapshot document : querySnapshot.get().getDocuments()) {
  System.out.println(document.getId());
}
পাইথন
museums = db.collection_group(u'landmarks')\
    .where(u'type', u'==', u'museum')
docs = museums.stream()
for doc in docs:
    print(f'{doc.id} => {doc.to_dict()}')

পাইথন

museums = db.collection_group("landmarks").where("type", "==", "museum")
docs = museums.stream()
async for doc in docs:
    print(f"{doc.id} => {doc.to_dict()}")
সি ++
// This is not yet supported.
Node.js
const querySnapshot = await db.collectionGroup('landmarks').where('type', '==', 'museum').get();
querySnapshot.forEach((doc) => {
  console.log(doc.id, ' => ', doc.data());
});
যাওয়া
import (
	"context"
	"fmt"
	"io"

	"cloud.google.com/go/firestore"
	"google.golang.org/api/iterator"
)

// collectionGroupQuery runs a collection group query over the data created by
// collectionGroupSetup.
func collectionGroupQuery(w io.Writer, projectID string) error {
	ctx := context.Background()

	client, err := firestore.NewClient(ctx, projectID)
	if err != nil {
		return fmt.Errorf("firestore.NewClient: %v", err)
	}
	defer client.Close()

	it := client.CollectionGroup("landmarks").Where("type", "==", "museum").Documents(ctx)
	for {
		doc, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("documents iterator: %v", err)
		}
		fmt.Fprintf(w, "%s: %s", doc.Ref.ID, doc.Data()["name"])
	}

	return nil
}
পিএইচপি
// Snippet not yet available
Unক্য
// Not yet supported in the Unity SDK
সি#
Query museums = db.CollectionGroup("landmarks").WhereEqualTo("Type", "museum");
QuerySnapshot querySnapshot = await museums.GetSnapshotAsync();
foreach (DocumentSnapshot document in querySnapshot.Documents)
{
    Console.WriteLine($"{document.Reference.Path}: {document.GetValue<string>("Name")}");
}
রুবি
museums = firestore.collection_group("landmarks").where("type", "==", "museum")
museums.get do |museum|
  puts "#{museum[:type]} name is #{museum[:name]}."
end

একটি সংগ্রহ গোষ্ঠী ক্যোয়ারী ব্যবহার করার আগে, আপনাকে অবশ্যই একটি সূচক তৈরি করতে হবে যা আপনার সংগ্রহ গোষ্ঠী ক্যোয়ারীকে সমর্থন করে। আপনি একটি ত্রুটির বার্তা, কনসোলে বা Firebase CLI মাধ্যমে একটি সূচক তৈরি করতে পারেন

ওয়েব এবং মোবাইল SDK আছে জন্য, আপনি আবশ্যক বিধি জারি করে যে আপনার সংগ্রহ গ্রুপ প্রশ্নের অনুমতি তৈরি

প্রশ্নের সীমাবদ্ধতা

নিম্নলিখিত তালিকা ক্লাউড ফায়ারস্টোর ক্যোয়ারী সীমাবদ্ধতার সংক্ষিপ্তসার:

  • ক্লাউড Firestore যৌক্তিক সীমিত সহায়তা প্রদান করে OR প্রশ্নের। in , এবং array-contains-any অপারেটার সমর্থন একটি লজিক্যাল OR 10 জন পর্যন্ত সমতার ( == ) অথবা array-contains একটি একক ক্ষেত্রের উপর শর্ত। অন্যান্য ক্ষেত্রে জন্য, প্রতিটি জন্য পৃথক কোয়েরি তৈরি OR অবস্থা এবং আপনার অ্যাপে অনুসন্ধানের ফলাফলগুলি চলে একত্রিত করে।
  • একটি যৌগ ক্যোয়ারীতে, পরিসর ( < , <= , > , >= ) এবং সমান ( != , not-in ) তুলনা অবশ্যই একই মাঠে সব ফিল্টার।
  • আপনি ব্যবহার করতে পারেন সর্বাধিক এক array-contains ক্যোয়ারী প্রতি দফা। আপনি একত্রিত করতে পারবেন না array-contains সঙ্গে array-contains-any
  • আপনি সবচেয়ে এক ব্যবহার করতে পারেন in , not-in , অথবা array-contains-any কোয়েরি প্রতি দফা। আপনি একত্রিত করতে পারবেন in , not-in , এবং array-contains-any একই ক্যোয়ারীতে।
  • আপনি (একটি ক্ষেত্র একটি সমতা অন্তর্ভুক্ত দ্বারা আপনার প্রশ্নের অর্ডার করতে পারবেন না == ) অথবা in দফা।
  • একটি প্রশ্নে ফিল্টার, সাজানোর আদেশ এবং মূল নথির পথ (একটি উপ -সংগ্রহের জন্য 1, একটি মূল সংগ্রহের জন্য 0) এর যোগফল 100 এর বেশি হতে পারে না।