توجد ثلاث طرق لاسترداد البيانات المخزنة في Cloud Firestore. يمكن استخدام أي من هذه الطرق مع المستندات أو مجموعات المستندات أو نتائج الاستعلامات:
- استدعاء طريقة للحصول على البيانات مرة واحدة.
- قم بتعيين مستمع لتلقي أحداث تغيير البيانات.
- تحميل مجمّع لبيانات لقطة Firestore من مصدر خارجي عبر حزم البيانات . انظر وثيقة الحزم لمزيد من التفاصيل.
عند تعيين مستمع ، يرسل Cloud Firestore للمستمع الخاص بك لقطة أولية للبيانات ، ثم لقطة أخرى في كل مرة يتغير فيها المستند.
قبل ان تبدأ
راجع بدء استخدام Cloud Firestore لإنشاء قاعدة بيانات Cloud Firestore.تهيئة Cloud Firestore
تهيئة مثيل Cloud Firestore:
Web modular API
import { initializeApp } from "firebase/app"; import { getFirestore } from "firebase/firestore"; // TODO: Replace the following with your app's Firebase project configuration // See: https://support.google.com/firebase/answer/7015592 const firebaseConfig = { FIREBASE_CONFIGURATION }; // Initialize Firebase const app = initializeApp(firebaseConfig); // Initialize Cloud Firestore and get a reference to the service const db = getFirestore(app);
استبدل FIREBASE_CONFIGURATION بـ firebaseConfig
لتطبيق الويب.
لاستمرار البيانات عندما يفقد الجهاز الاتصال ، راجع توثيق تمكين البيانات غير المتصلة .
Web namespaced API
import firebase from "firebase/app"; import "firebase/firestore"; // TODO: Replace the following with your app's Firebase project configuration // See: https://support.google.com/firebase/answer/7015592 const firebaseConfig = { FIREBASE_CONFIGURATION }; // Initialize Firebase firebase.initializeApp(firebaseConfig); // Initialize Cloud Firestore and get a reference to the service const db = firebase.firestore();
استبدل FIREBASE_CONFIGURATION بـ firebaseConfig
لتطبيق الويب.
لاستمرار البيانات عندما يفقد الجهاز الاتصال ، راجع توثيق تمكين البيانات غير المتصلة .
سويفت
import FirebaseCore import FirebaseFirestore
FirebaseApp.configure() let db = Firestore.firestore()
ج موضوعية
@import FirebaseCore; @import FirebaseFirestore; // Use Firebase library to configure APIs [FIRApp configure];
FIRFirestore *defaultFirestore = [FIRFirestore firestore];
Kotlin+KTX
// Access a Cloud Firestore instance from your Activity
val db = Firebase.firestore
Java
// Access a Cloud Firestore instance from your Activity
FirebaseFirestore db = FirebaseFirestore.getInstance();
Dart
db = FirebaseFirestore.instance;
جافا
تتم تهيئة Cloud Firestore SDK بطرق مختلفة اعتمادًا على بيئتك. فيما يلي الطرق الأكثر شيوعًا. للحصول على مرجع كامل ، راجع تهيئة Admin SDK .import com.google.auth.oauth2.GoogleCredentials; import com.google.cloud.firestore.Firestore; import com.google.firebase.FirebaseApp; import com.google.firebase.FirebaseOptions; // Use the application default credentials GoogleCredentials credentials = GoogleCredentials.getApplicationDefault(); FirebaseOptions options = new FirebaseOptions.Builder() .setCredentials(credentials) .setProjectId(projectId) .build(); FirebaseApp.initializeApp(options); Firestore db = FirestoreClient.getFirestore();
لاستخدام Firebase Admin SDK على خادمك الخاص ، استخدم حساب الخدمة .
انتقل إلى IAM والمسؤول> حسابات الخدمة في وحدة تحكم Google Cloud. أنشئ مفتاحًا خاصًا جديدًا واحفظ ملف JSON. ثم استخدم الملف لتهيئة SDK:
import com.google.auth.oauth2.GoogleCredentials; import com.google.cloud.firestore.Firestore; import com.google.firebase.FirebaseApp; import com.google.firebase.FirebaseOptions; // Use a service account InputStream serviceAccount = new FileInputStream("path/to/serviceAccount.json"); GoogleCredentials credentials = GoogleCredentials.fromStream(serviceAccount); FirebaseOptions options = new FirebaseOptions.Builder() .setCredentials(credentials) .build(); FirebaseApp.initializeApp(options); Firestore db = FirestoreClient.getFirestore();
بايثون
تتم تهيئة Cloud Firestore SDK بطرق مختلفة اعتمادًا على بيئتك. فيما يلي الطرق الأكثر شيوعًا. للحصول على مرجع كامل ، راجع تهيئة Admin SDK .import firebase_admin from firebase_admin import firestore # Application Default credentials are automatically created. app = firebase_admin.initialize_app() db = firestore.client()
يمكن أيضًا استخدام بيانات اعتماد افتراضية للتطبيق الحالي لتهيئة SDK.
import firebase_admin from firebase_admin import credentials from firebase_admin import firestore # Use the application default credentials. cred = credentials.ApplicationDefault() firebase_admin.initialize_app(cred) db = firestore.client()
لاستخدام Firebase Admin SDK على خادمك الخاص ، استخدم حساب الخدمة .
انتقل إلى IAM والمسؤول> حسابات الخدمة في وحدة تحكم Google Cloud. أنشئ مفتاحًا خاصًا جديدًا واحفظ ملف JSON. ثم استخدم الملف لتهيئة SDK:
import firebase_admin from firebase_admin import credentials from firebase_admin import firestore # Use a service account. cred = credentials.Certificate('path/to/serviceAccount.json') app = firebase_admin.initialize_app(cred) db = firestore.client()
Python
تتم تهيئة Cloud Firestore SDK بطرق مختلفة اعتمادًا على بيئتك. فيما يلي الطرق الأكثر شيوعًا. للحصول على مرجع كامل ، راجع تهيئة Admin SDK .import firebase_admin from firebase_admin import firestore_async # Application Default credentials are automatically created. app = firebase_admin.initialize_app() db = firestore_async.client()
يمكن أيضًا استخدام بيانات اعتماد افتراضية للتطبيق الحالي لتهيئة SDK.
import firebase_admin from firebase_admin import credentials from firebase_admin import firestore_async # Use the application default credentials. cred = credentials.ApplicationDefault() firebase_admin.initialize_app(cred) db = firestore_async.client()
لاستخدام Firebase Admin SDK على خادمك الخاص ، استخدم حساب الخدمة .
انتقل إلى IAM والمسؤول> حسابات الخدمة في وحدة تحكم Google Cloud. أنشئ مفتاحًا خاصًا جديدًا واحفظ ملف JSON. ثم استخدم الملف لتهيئة SDK:
import firebase_admin from firebase_admin import credentials from firebase_admin import firestore_async # Use a service account. cred = credentials.Certificate('path/to/serviceAccount.json') app = firebase_admin.initialize_app(cred) db = firestore_async.client()
C ++
// Make sure the call to `Create()` happens some time before you call Firestore::GetInstance(). App::Create(); Firestore* db = Firestore::GetInstance();
Node.js
تتم تهيئة Cloud Firestore SDK بطرق مختلفة اعتمادًا على بيئتك. فيما يلي الطرق الأكثر شيوعًا. للحصول على مرجع كامل ، راجع تهيئة Admin SDK .- التهيئة على وظائف السحابة
const { initializeApp, applicationDefault, cert } = require('firebase-admin/app'); const { getFirestore, Timestamp, FieldValue, Filter } = require('firebase-admin/firestore');
initializeApp(); const db = getFirestore();
- التهيئة على Google Cloud
const { initializeApp, applicationDefault, cert } = require('firebase-admin/app'); const { getFirestore, Timestamp, FieldValue, Filter } = require('firebase-admin/firestore');
initializeApp({ credential: applicationDefault() }); const db = getFirestore();
- التهيئة على الخادم الخاص بك
لاستخدام Firebase Admin SDK على الخادم الخاص بك (أو أي بيئة Node.js أخرى) ، استخدم حساب الخدمة . انتقل إلى IAM والمسؤول> حسابات الخدمة في وحدة تحكم Google Cloud. أنشئ مفتاحًا خاصًا جديدًا واحفظ ملف JSON. ثم استخدم الملف لتهيئة SDK:
const { initializeApp, applicationDefault, cert } = require('firebase-admin/app'); const { getFirestore, Timestamp, FieldValue, Filter } = require('firebase-admin/firestore');
const serviceAccount = require('./path/to/serviceAccountKey.json'); initializeApp({ credential: cert(serviceAccount) }); const db = getFirestore();
يذهب
تتم تهيئة Cloud Firestore SDK بطرق مختلفة اعتمادًا على بيئتك. فيما يلي الطرق الأكثر شيوعًا. للحصول على مرجع كامل ، راجع تهيئة Admin SDK .import ( "log" firebase "firebase.google.com/go" "google.golang.org/api/option" ) // Use the application default credentials ctx := context.Background() conf := &firebase.Config{ProjectID: projectID} app, err := firebase.NewApp(ctx, conf) if err != nil { log.Fatalln(err) } client, err := app.Firestore(ctx) if err != nil { log.Fatalln(err) } defer client.Close()
لاستخدام Firebase Admin SDK على خادمك الخاص ، استخدم حساب الخدمة .
انتقل إلى IAM والمسؤول> حسابات الخدمة في وحدة تحكم Google Cloud. أنشئ مفتاحًا خاصًا جديدًا واحفظ ملف JSON. ثم استخدم الملف لتهيئة SDK:
import ( "log" firebase "firebase.google.com/go" "google.golang.org/api/option" ) // Use a service account ctx := context.Background() sa := option.WithCredentialsFile("path/to/serviceAccount.json") app, err := firebase.NewApp(ctx, nil, sa) if err != nil { log.Fatalln(err) } client, err := app.Firestore(ctx) if err != nil { log.Fatalln(err) } defer client.Close()
بي أتش بي
بي أتش بي
لمزيد من المعلومات حول تثبيت عميل Cloud Firestore وإنشائه ، راجع مكتبات Cloud Firestore Client Libraries .
وحدة
using Firebase.Firestore; using Firebase.Extensions;
FirebaseFirestore db = FirebaseFirestore.DefaultInstance;
سي #
سي #
لمزيد من المعلومات حول تثبيت عميل Cloud Firestore وإنشائه ، راجع مكتبات Cloud Firestore Client Libraries .
روبي
مثال على البيانات
للبدء ، اكتب بعض البيانات عن المدن حتى نتمكن من البحث عن طرق مختلفة لقراءتها مرة أخرى:
Web modular API
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"] });
Web namespaced API
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"] }];
Kotlin+KTX
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)
Java
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);
Dart
final cities = db.collection("cities"); final data1 = <String, dynamic>{ "name": "San Francisco", "state": "CA", "country": "USA", "capital": false, "population": 860000, "regions": ["west_coast", "norcal"] }; cities.doc("SF").set(data1); final data2 = <String, dynamic>{ "name": "Los Angeles", "state": "CA", "country": "USA", "capital": false, "population": 3900000, "regions": ["west_coast", "socal"], }; cities.doc("LA").set(data2); final data3 = <String, dynamic>{ "name": "Washington D.C.", "state": null, "country": "USA", "capital": true, "population": 680000, "regions": ["east_coast"] }; cities.doc("DC").set(data3); final data4 = <String, dynamic>{ "name": "Tokyo", "state": null, "country": "Japan", "capital": true, "population": 9000000, "regions": ["kanto", "honshu"] }; cities.doc("TOK").set(data4); final data5 = <String, dynamic>{ "name": "Beijing", "state": null, "country": "China", "capital": true, "population": 21500000, "regions": ["jingjinji", "hebei"], }; cities.doc("BJ").set(data5);
جافا
بايثون
class City: 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') cities_ref.document('BJ').set( City('Beijing', None, 'China', True, 21500000, ['hebei']).to_dict()) cities_ref.document('SF').set( City('San Francisco', 'CA', 'USA', False, 860000, ['west_coast', 'norcal']).to_dict()) cities_ref.document('LA').set( City('Los Angeles', 'CA', 'USA', False, 3900000, ['west_coast', 'socal']).to_dict()) cities_ref.document('DC').set( City('Washington D.C.', None, 'USA', True, 680000, ['east_coast']).to_dict()) cities_ref.document('TOK').set( City('Tokyo', None, 'Japan', True, 9000000, ['kanto', 'honshu']).to_dict())
Python
C ++
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
يذهب
بي أتش بي
بي أتش بي
لمزيد من المعلومات حول تثبيت عميل Cloud Firestore وإنشائه ، راجع مكتبات Cloud Firestore Client Libraries .
وحدة
CollectionReference citiesRef = db.Collection("cities"); citiesRef.Document("SF").SetAsync(new Dictionary<string, object>(){ { "Name", "San Francisco" }, { "State", "CA" }, { "Country", "USA" }, { "Capital", false }, { "Population", 860000 } }).ContinueWithOnMainThread(task => citiesRef.Document("LA").SetAsync(new Dictionary<string, object>(){ { "Name", "Los Angeles" }, { "State", "CA" }, { "Country", "USA" }, { "Capital", false }, { "Population", 3900000 } }) ).ContinueWithOnMainThread(task => citiesRef.Document("DC").SetAsync(new Dictionary<string, object>(){ { "Name", "Washington D.C." }, { "State", null }, { "Country", "USA" }, { "Capital", true }, { "Population", 680000 } }) ).ContinueWithOnMainThread(task => citiesRef.Document("TOK").SetAsync(new Dictionary<string, object>(){ { "Name", "Tokyo" }, { "State", null }, { "Country", "Japan" }, { "Capital", true }, { "Population", 9000000 } }) ).ContinueWithOnMainThread(task => citiesRef.Document("BJ").SetAsync(new Dictionary<string, object>(){ { "Name", "Beijing" }, { "State", null }, { "Country", "China" }, { "Capital", true }, { "Population", 21500000 } }) );
سي #
روبي
احصل على وثيقة
يوضح المثال التالي كيفية استرداد محتويات مستند واحد باستخدام get()
:
Web modular API
import { doc, getDoc } from "firebase/firestore"; const docRef = doc(db, "cities", "SF"); const docSnap = await getDoc(docRef); if (docSnap.exists()) { console.log("Document data:", docSnap.data()); } else { // docSnap.data() will be undefined in this case console.log("No such document!"); }
Web namespaced API
var docRef = db.collection("cities").doc("SF"); docRef.get().then((doc) => { if (doc.exists) { console.log("Document data:", doc.data()); } else { // doc.data() will be undefined in this case console.log("No such document!"); } }).catch((error) => { console.log("Error getting document:", error); });
سويفت
let docRef = db.collection("cities").document("SF") docRef.getDocument { (document, error) in if let document = document, document.exists { let dataDescription = document.data().map(String.init(describing:)) ?? "nil" print("Document data: \(dataDescription)") } else { print("Document does not exist") } }
ج موضوعية
FIRDocumentReference *docRef = [[self.db collectionWithPath:@"cities"] documentWithPath:@"SF"]; [docRef getDocumentWithCompletion:^(FIRDocumentSnapshot *snapshot, NSError *error) { if (snapshot.exists) { // Document data may be nil if the document exists but has no keys or values. NSLog(@"Document data: %@", snapshot.data); } else { NSLog(@"Document does not exist"); } }];
Kotlin+KTX
val docRef = db.collection("cities").document("SF") docRef.get() .addOnSuccessListener { document -> if (document != null) { Log.d(TAG, "DocumentSnapshot data: ${document.data}") } else { Log.d(TAG, "No such document") } } .addOnFailureListener { exception -> Log.d(TAG, "get failed with ", exception) }
Java
DocumentReference docRef = db.collection("cities").document("SF"); docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() { @Override public void onComplete(@NonNull Task<DocumentSnapshot> task) { if (task.isSuccessful()) { DocumentSnapshot document = task.getResult(); if (document.exists()) { Log.d(TAG, "DocumentSnapshot data: " + document.getData()); } else { Log.d(TAG, "No such document"); } } else { Log.d(TAG, "get failed with ", task.getException()); } } });
Dart
final docRef = db.collection("cities").doc("SF"); docRef.get().then( (DocumentSnapshot doc) { final data = doc.data() as Map<String, dynamic>; // ... }, onError: (e) => print("Error getting document: $e"), );
جافا
بايثون
Python
C ++
DocumentReference doc_ref = db->Collection("cities").Document("SF"); doc_ref.Get().OnCompletion([](const Future<DocumentSnapshot>& future) { if (future.error() == Error::kErrorOk) { const DocumentSnapshot& document = *future.result(); if (document.exists()) { std::cout << "DocumentSnapshot id: " << document.id() << std::endl; } else { std::cout << "no such document" << std::endl; } } else { std::cout << "Get failed with: " << future.error_message() << std::endl; } });
Node.js
يذهب
بي أتش بي
بي أتش بي
لمزيد من المعلومات حول تثبيت عميل Cloud Firestore وإنشائه ، راجع مكتبات Cloud Firestore Client Libraries .
وحدة
DocumentReference docRef = db.Collection("cities").Document("SF"); docRef.GetSnapshotAsync().ContinueWithOnMainThread(task => { DocumentSnapshot snapshot = task.Result; if (snapshot.Exists) { Debug.Log(String.Format("Document data for {0} document:", snapshot.Id)); Dictionary<string, object> city = snapshot.ToDictionary(); foreach (KeyValuePair<string, object> pair in city) { Debug.Log(String.Format("{0}: {1}", pair.Key, pair.Value)); } } else { Debug.Log(String.Format("Document {0} does not exist!", snapshot.Id)); } });
سي #
روبي
خيارات المصدر
بالنسبة إلى الأنظمة الأساسية التي تدعم وضع عدم الاتصال ، يمكنك تعيين خيار source
للتحكم في كيفية استخدام ميزة get
مكالمة" لذاكرة التخزين المؤقت غير المتصلة بالإنترنت.
بشكل افتراضي ، سيحاول get
جلب أحدث لقطة للمستند من قاعدة البيانات الخاصة بك. في الأنظمة الأساسية التي تدعم وضع عدم الاتصال ، ستستخدم مكتبة العميل ذاكرة التخزين المؤقت دون اتصال إذا كانت الشبكة غير متوفرة أو إذا انتهت مهلة الطلب.
يمكنك تحديد خيار source
في استدعاء get()
لتغيير السلوك الافتراضي. يمكنك الجلب من قاعدة البيانات فقط وتجاهل ذاكرة التخزين المؤقت دون اتصال ، أو يمكنك الجلب من ذاكرة التخزين المؤقت غير المتصلة فقط. على سبيل المثال:
Web modular API
import { doc, getDocFromCache } from "firebase/firestore"; const docRef = doc(db, "cities", "SF"); // Get a document, forcing the SDK to fetch from the offline cache. try { const doc = await getDocFromCache(docRef); // Document was found in the cache. If no cached document exists, // an error will be returned to the 'catch' block below. console.log("Cached document data:", doc.data()); } catch (e) { console.log("Error getting cached document:", e); }
Web namespaced API
var docRef = db.collection("cities").doc("SF"); // Valid options for source are 'server', 'cache', or // 'default'. See https://firebase.google.com/docs/reference/js/v8/firebase.firestore.GetOptions // for more information. var getOptions = { source: 'cache' }; // Get a document, forcing the SDK to fetch from the offline cache. docRef.get(getOptions).then((doc) => { // Document was found in the cache. If no cached document exists, // an error will be returned to the 'catch' block below. console.log("Cached document data:", doc.data()); }).catch((error) => { console.log("Error getting cached document:", error); });
سويفت
let docRef = db.collection("cities").document("SF") // Force the SDK to fetch the document from the cache. Could also specify // FirestoreSource.server or FirestoreSource.default. docRef.getDocument(source: .cache) { (document, error) in if let document = document { let dataDescription = document.data().map(String.init(describing:)) ?? "nil" print("Cached document data: \(dataDescription)") } else { print("Document does not exist in cache") } }
ج موضوعية
FIRDocumentReference *docRef = [[self.db collectionWithPath:@"cities"] documentWithPath:@"SF"]; // Force the SDK to fetch the document from the cache. Could also specify // FIRFirestoreSourceServer or FIRFirestoreSourceDefault. [docRef getDocumentWithSource:FIRFirestoreSourceCache completion:^(FIRDocumentSnapshot *snapshot, NSError *error) { if (snapshot != NULL) { // The document data was found in the cache. NSLog(@"Cached document data: %@", snapshot.data); } else { // The document data was not found in the cache. NSLog(@"Document does not exist in cache: %@", error); } }];
Kotlin+KTX
val docRef = db.collection("cities").document("SF") // Source can be CACHE, SERVER, or DEFAULT. val source = Source.CACHE // Get the document, forcing the SDK to use the offline cache docRef.get(source).addOnCompleteListener { task -> if (task.isSuccessful) { // Document found in the offline cache val document = task.result Log.d(TAG, "Cached document data: ${document?.data}") } else { Log.d(TAG, "Cached get failed: ", task.exception) } }
Java
DocumentReference docRef = db.collection("cities").document("SF"); // Source can be CACHE, SERVER, or DEFAULT. Source source = Source.CACHE; // Get the document, forcing the SDK to use the offline cache docRef.get(source).addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() { @Override public void onComplete(@NonNull Task<DocumentSnapshot> task) { if (task.isSuccessful()) { // Document found in the offline cache DocumentSnapshot document = task.getResult(); Log.d(TAG, "Cached document data: " + document.getData()); } else { Log.d(TAG, "Cached get failed: ", task.getException()); } } });
Dart
final docRef = db.collection("cities").doc("SF"); // Source can be CACHE, SERVER, or DEFAULT. const source = Source.cache; docRef.get(const GetOptions(source: source)).then( (res) => print("Successfully completed"), onError: (e) => print("Error completing: $e"), );
جافا
غير مدعوم في Java SDK.
بايثون
غير مدعوم في Python SDK.
C ++
DocumentReference doc_ref = db->Collection("cities").Document("SF"); Source source = Source::kCache; doc_ref.Get(source).OnCompletion([](const Future<DocumentSnapshot>& future) { if (future.error() == Error::kErrorOk) { const DocumentSnapshot& document = *future.result(); if (document.exists()) { std::cout << "Cached document id: " << document.id() << std::endl; } else { } } else { std::cout << "Cached get failed: " << future.error_message() << std::endl; } });
Node.js
غير مدعوم في Node.js SDK.
يذهب
غير مدعوم في Go SDK.
بي أتش بي
غير مدعوم في PHP SDK.
وحدة
غير مدعوم في Unity SDK.
سي #
غير مدعوم في C # SDK.
روبي
غير مدعوم في Ruby SDK.
كائنات مخصصة
استرد المثال السابق محتويات المستند كخريطة ، ولكن في بعض اللغات يكون استخدام نوع كائن مخصص أكثر ملاءمة. في إضافة البيانات ، قمت بتعريف فئة City
التي استخدمتها لتحديد كل مدينة. يمكنك إعادة المستند إلى كائن City
:
لاستخدام كائنات مخصصة ، يجب عليك تحديد وظيفة FirestoreDataConverter لفصلك الدراسي. على سبيل المثال:
Web modular API
class City { constructor (name, state, country ) { this.name = name; this.state = state; this.country = country; } toString() { return this.name + ', ' + this.state + ', ' + this.country; } } // Firestore data converter const cityConverter = { toFirestore: (city) => { return { name: city.name, state: city.state, country: city.country }; }, fromFirestore: (snapshot, options) => { const data = snapshot.data(options); return new City(data.name, data.state, data.country); } };
لاستخدام كائنات مخصصة ، يجب عليك تحديد وظيفة FirestoreDataConverter لفصلك الدراسي. على سبيل المثال:
Web namespaced API
class City { constructor (name, state, country ) { this.name = name; this.state = state; this.country = country; } toString() { return this.name + ', ' + this.state + ', ' + this.country; } } // Firestore data converter var cityConverter = { toFirestore: function(city) { return { name: city.name, state: city.state, country: city.country }; }, fromFirestore: function(snapshot, options){ const data = snapshot.data(options); return new City(data.name, data.state, data.country); } };
استدعاء محول البيانات الخاص بك مع عمليات القراءة الخاصة بك. بعد التحويل ، يمكنك الوصول إلى طرق الكائنات المخصصة:
Web modular API
import { doc, getDoc} from "firebase/firestore"; const ref = doc(db, "cities", "LA").withConverter(cityConverter); const docSnap = await getDoc(ref); if (docSnap.exists()) { // Convert to City object const city = docSnap.data(); // Use a City instance method console.log(city.toString()); } else { console.log("No such document!"); }
استدعاء محول البيانات الخاص بك مع عمليات القراءة الخاصة بك. بعد التحويل ، يمكنك الوصول إلى طرق الكائنات المخصصة:
Web namespaced API
db.collection("cities").doc("LA") .withConverter(cityConverter) .get().then((doc) => { if (doc.exists){ // Convert to City object var city = doc.data(); // Use a City instance method console.log(city.toString()); } else { console.log("No such document!"); }}).catch((error) => { console.log("Error getting document:", error); });
سويفت
لدعم تسلسل النوع التلقائي في Swift ، يجب أن يتوافق النوع الخاص بك مع بروتوكول Codable ويجب عليك تضمين pod 'FirebaseFirestoreSwift'
كعنصر تبعية لمشروعك.
let docRef = db.collection("cities").document("BJ") docRef.getDocument(as: City.self) { result in // The Result type encapsulates deserialization errors or // successful deserialization, and can be handled as follows: // // Result // /\ // Error City switch result { case .success(let city): // A `City` value was successfully initialized from the DocumentSnapshot. print("City: \(city)") case .failure(let error): // A `City` value could not be initialized from the DocumentSnapshot. print("Error decoding city: \(error)") } }
ج موضوعية
في Objective-C ، يجب عليك القيام بذلك يدويًا.
FIRDocumentReference *docRef = [[self.db collectionWithPath:@"cities"] documentWithPath:@"BJ"]; [docRef getDocumentWithCompletion:^(FIRDocumentSnapshot *snapshot, NSError *error) { FSTCity *city = [[FSTCity alloc] initWithDictionary:snapshot.data]; if (city != nil) { NSLog(@"City: %@", city); } else { NSLog(@"Document does not exist"); } }];
Kotlin+KTX
val docRef = db.collection("cities").document("BJ") docRef.get().addOnSuccessListener { documentSnapshot -> val city = documentSnapshot.toObject<City>() }
Java
هام: يجب أن يكون لكل فئة مخصصة مُنشئ عام لا يأخذ أي وسيطات. بالإضافة إلى ذلك ، يجب أن يتضمن الفصل الدراسي جامعًا عامًا لكل ملكية.
DocumentReference docRef = db.collection("cities").document("BJ"); docRef.get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() { @Override public void onSuccess(DocumentSnapshot documentSnapshot) { City city = documentSnapshot.toObject(City.class); } });
Dart
لاستخدام كائنات مخصصة ، يجب عليك تحديد وظائف تحويل بيانات Firestore لفصلك الدراسي. على سبيل المثال:
class City { final String? name; final String? state; final String? country; final bool? capital; final int? population; final List<String>? regions; City({ this.name, this.state, this.country, this.capital, this.population, this.regions, }); factory City.fromFirestore( DocumentSnapshot<Map<String, dynamic>> snapshot, SnapshotOptions? options, ) { final data = snapshot.data(); return City( name: data?['name'], state: data?['state'], country: data?['country'], capital: data?['capital'], population: data?['population'], regions: data?['regions'] is Iterable ? List.from(data?['regions']) : null, ); } Map<String, dynamic> toFirestore() { return { if (name != null) "name": name, if (state != null) "state": state, if (country != null) "country": country, if (capital != null) "capital": capital, if (population != null) "population": population, if (regions != null) "regions": regions, }; } }
بعد ذلك ، قم بإنشاء مرجع مستند باستخدام وظائف تحويل البيانات الخاصة بك. ستُرجع أي عمليات قراءة تجريها باستخدام هذا المرجع مثيلات لفصلك المخصص:
final ref = db.collection("cities").doc("LA").withConverter( fromFirestore: City.fromFirestore, toFirestore: (City city, _) => city.toFirestore(), ); final docSnap = await ref.get(); final city = docSnap.data(); // Convert to City object if (city != null) { print(city); } else { print("No such document."); }
جافا
يجب أن يكون لكل فئة مخصصة مُنشئ عام لا يأخذ أي وسيطات. بالإضافة إلى ذلك ، يجب أن يتضمن الفصل الدراسي جامعًا عامًا لكل ملكية.
بايثون
Python
C ++
// This is not yet supported.
Node.js
يستخدم Node.js كائنات JavaScript.
يذهب
بي أتش بي
بي أتش بي
لمزيد من المعلومات حول تثبيت عميل Cloud Firestore وإنشائه ، راجع مكتبات Cloud Firestore Client Libraries .
وحدة
DocumentReference docRef = db.Collection("cities").Document("BJ"); docRef.GetSnapshotAsync().ContinueWith((task) => { var snapshot = task.Result; if (snapshot.Exists) { Debug.Log(String.Format("Document data for {0} document:", snapshot.Id)); City city = snapshot.ConvertTo<City>(); Debug.Log(String.Format("Name: {0}", city.Name)); Debug.Log(String.Format("State: {0}", city.State)); Debug.Log(String.Format("Country: {0}", city.Country)); Debug.Log(String.Format("Capital: {0}", city.Capital)); Debug.Log(String.Format("Population: {0}", city.Population)); } else { Debug.Log(String.Format("Document {0} does not exist!", snapshot.Id)); } });
سي #
روبي
لا ينطبق على روبي.
احصل على مستندات متعددة من مجموعة
يمكنك أيضًا استرداد مستندات متعددة بطلب واحد عن طريق الاستعلام عن المستندات في المجموعة. على سبيل المثال ، يمكنك استخدام where()
للاستعلام عن جميع المستندات التي تفي بشرط معين ، ثم استخدام get()
لاسترداد النتائج:
Web modular API
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()); });
Web namespaced API
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); } } }];
Kotlin+KTX
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) }
Java
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()); } } });
Dart
db.collection("cities").where("capital", isEqualTo: true).get().then( (querySnapshot) { print("Successfully completed"); for (var docSnapshot in querySnapshot.docs) { print('${docSnapshot.id} => ${docSnapshot.data()}'); } }, onError: (e) => print("Error completing: $e"), );
جافا
بايثون
Python
C ++
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 << std::endl; } } else { std::cout << "Error getting documents: " << future.error_message() << std::endl; } });
Node.js
يذهب
بي أتش بي
بي أتش بي
لمزيد من المعلومات حول تثبيت عميل Cloud Firestore وإنشائه ، راجع مكتبات Cloud Firestore Client Libraries .
وحدة
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(""); }; });
سي #
روبي
بشكل افتراضي ، يسترد Cloud Firestore جميع المستندات التي تلبي الاستعلام بترتيب تصاعدي حسب معرف المستند ، ولكن يمكنك طلب البيانات التي يتم إرجاعها والحد منها .
احصل على جميع المستندات في مجموعة
بالإضافة إلى ذلك ، يمكنك استرداد جميع المستندات في مجموعة عن طريق حذف عامل التصفية where()
بالكامل:
Web modular API
import { collection, getDocs } from "firebase/firestore"; const querySnapshot = await getDocs(collection(db, "cities")); querySnapshot.forEach((doc) => { // doc.data() is never undefined for query doc snapshots console.log(doc.id, " => ", doc.data()); });
Web namespaced API
db.collection("cities").get().then((querySnapshot) => { querySnapshot.forEach((doc) => { // doc.data() is never undefined for query doc snapshots console.log(doc.id, " => ", doc.data()); }); });
سويفت
db.collection("cities").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"] 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); } } }];
Kotlin+KTX
db.collection("cities") .get() .addOnSuccessListener { result -> for (document in result) { Log.d(TAG, "${document.id} => ${document.data}") } } .addOnFailureListener { exception -> Log.d(TAG, "Error getting documents: ", exception) }
Java
db.collection("cities") .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()); } } });
Dart
db.collection("cities").get().then( (querySnapshot) { print("Successfully completed"); for (var docSnapshot in querySnapshot.docs) { print('${docSnapshot.id} => ${docSnapshot.data()}'); } }, onError: (e) => print("Error completing: $e"), );
جافا
بايثون
Python
C ++
db->Collection("cities").Get().OnCompletion( [](const Future<QuerySnapshot>& future) { if (future.error() == Error::kErrorOk) { for (const DocumentSnapshot& document : future.result()->documents()) { std::cout << document << std::endl; } } else { std::cout << "Error getting documents: " << future.error_message() << std::endl; } });
Node.js
يذهب
بي أتش بي
بي أتش بي
لمزيد من المعلومات حول تثبيت عميل Cloud Firestore وإنشائه ، راجع مكتبات Cloud Firestore Client Libraries .
وحدة
Query allCitiesQuery = db.Collection("cities"); allCitiesQuery.GetSnapshotAsync().ContinueWithOnMainThread(task => { QuerySnapshot allCitiesQuerySnapshot = task.Result; foreach (DocumentSnapshot documentSnapshot in allCitiesQuerySnapshot.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(""); } });
سي #
روبي
احصل على جميع المستندات في مجموعة فرعية
لاسترداد جميع المستندات من مجموعة فرعية ، قم بإنشاء مرجع بالمسار الكامل لتلك المجموعة الفرعية:
Web modular API
const { collection, getDocs } = require("firebase/firestore"); // Query a reference to a subcollection const querySnapshot = await getDocs(collection(db, "cities", "SF", "landmarks")); querySnapshot.forEach((doc) => { // doc.data() is never undefined for query doc snapshots console.log(doc.id, " => ", doc.data()); });
Web namespaced API
// Snippet not available
سويفت
db.collection("cities/SF/landmarks").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/SF/landmarks"] 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); } } }];
Kotlin+KTX
db.collection("cities") .document("SF") .collection("landmarks") .get() .addOnSuccessListener { result -> for (document in result) { Log.d(TAG, "${document.id} => ${document.data}") } } .addOnFailureListener { exception -> Log.d(TAG, "Error getting documents: ", exception) }
Java
db.collection("cities") .document("SF") .collection("landmarks") .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()); } } });
Dart
db.collection("cities").doc("SF").collection("landmarks").get().then( (querySnapshot) { print("Successfully completed"); for (var docSnapshot in querySnapshot.docs) { print('${docSnapshot.id} => ${docSnapshot.data()}'); } }, onError: (e) => print("Error completing: $e"), );
جافا
// Snippet not available
بايثون
// Snippet not available
Python
// Snippet not available
C ++
// Snippet not available
Node.js
// Snippet not available
يذهب
// Snippet not available
بي أتش بي
// Snippet not available
وحدة
// Snippet not available
سي #
// Snippet not available
روبي
// Snippet not available
احصل على مستندات متعددة من مجموعة تجميع
تتكون مجموعة التجميع من جميع المجموعات التي لها نفس المعرف. على سبيل المثال ، إذا كان كل مستند في مجموعة cities
الخاصة بك يحتوي على مجموعة فرعية تسمى landmarks
، فإن كل المجموعات الفرعية landmarks
تنتمي إلى نفس مجموعة المجموعة. بشكل افتراضي ، تسترد الاستعلامات النتائج من مجموعة واحدة في قاعدة البيانات الخاصة بك. استخدم استعلام مجموعة المجموعة لاسترداد النتائج من مجموعة مجموعة بدلاً من مجموعة واحدة.
سرد المجموعات الفرعية من المستند
تسرد طريقة listCollections()
لمكتبات عميل خادم Cloud Firestore جميع المجموعات الفرعية لمرجع المستند.
لا يمكن استرداد قائمة المجموعات باستخدام مكتبات عميل الويب / الجوال. يجب فقط البحث عن أسماء المجموعات كجزء من المهام الإدارية في بيئات الخادم الموثوق بها. إذا وجدت أنك بحاجة إلى هذه الإمكانية في مكتبات عميل الجوال / الويب ، ففكر في إعادة هيكلة بياناتك بحيث يمكن التنبؤ بأسماء المجموعات الفرعية.
الويب
غير متوفر في مكتبة عميل الويب.
سويفت
غير متوفر في مكتبة عميل Swift.
ج موضوعية
غير متوفر في مكتبة العميل Objective-C.
Kotlin+KTX
غير متوفر في مكتبة عميل Android.
Java
غير متوفر في مكتبة عميل Android.
Dart
غير متوفر في مكتبة عميل Flutter.
جافا
بايثون
Python
C ++
غير متوفر في مكتبة العميل C ++.
Node.js
يذهب
بي أتش بي
بي أتش بي
لمزيد من المعلومات حول تثبيت عميل Cloud Firestore وإنشائه ، راجع مكتبات Cloud Firestore Client Libraries .
وحدة
// This is not yet supported in the Unity SDK.
سي #
روبي
تعرف على المزيد حول أنواع الاستعلامات المختلفة.
لمزيد من المعلومات حول رموز الخطأ وكيفية حل مشكلات وقت الاستجابة عند الحصول على البيانات ، راجع صفحة استكشاف الأخطاء وإصلاحها .