Cloud Firestore'u kullanmaya başlama

Bu hızlı başlangıç kılavuzunda, Cloud Firestore'u nasıl kuracağınız, veri ekleyip görüntüleyeceğiniz gösterilmektedir Firebase konsoluna eklediğiniz veriler.

Cloud Firestore veritabanı oluşturma

  1. Henüz yapmadıysanız bir Firebase projesi oluşturun: Firebase konsolunda Proje ekle'yi tıklayın, Ardından ekrandaki talimatları uygulayarak Firebase projesi oluşturun veya Firebase hizmetlerini mevcut bir GCP projesine ekleme.

  2. Etiketin Cloud Firestore bölümüne gidin Firebase konsolu. Mevcut bir Firebase projesini seçmeniz istenir. Veritabanı oluşturma iş akışını takip edin.

  3. Cloud Firestore Güvenlik Kurallarınız için bir başlangıç modu seçin:

    Test modu

    Mobil ve web istemci kitaplıklarını kullanmaya başlamak için idealdir. ancak herkesin verilerinizi okumasına ve üzerine yazmasına izin verir. Testten sonra, Verilerinizin güvenliğini sağlama bölümünü inceleyin.

    Web, Apple platformları veya Android SDK'yı kullanmaya başlamak için test modunu seçin.

    Kilitli mod

    Mobil istemcilerden ve web istemcilerinden tüm okuma ve yazma işlemlerini reddeder. Kimliği doğrulanmış uygulama sunucularınız (C#, Go, Java, Node.js, PHP, Python veya Ruby) veritabanınıza erişmeye devam edebilir.

    C#, Go, Java, Node.js, PHP, Python veya Ruby'yi kullanmaya başlamak için sunucu istemci kitaplığı, kilitli modu seçin.

    İlk Cloud Firestore Güvenlik Kurallarınız, varsayılan ayarınız için geçerli olur. Cloud Firestore veritabanı. Projeniz için birden fazla veritabanı oluşturursanız her veritabanı için Cloud Firestore Güvenlik Kuralları'nı dağıtabilirsiniz.

  4. Veritabanınız için bir konum seçin.

    • Bu konum ayarı, projenizin varsayılan Google Cloud Platform (GCP) kaynak konumu. Bu konumun, projenizdeki GCP hizmetleri için kullanılacağını unutmayın ve konum ayarı gerektiren varsayılan Cloud Storage paketi ve App Engine uygulaması ( (Cloud Scheduler kullanıyorsanız gereklidir).

    • Konum seçemiyorsanız projeniz zaten varsayılan bir GCP kaynak konumuna sahip. Proje sırasında konum gerektiren başka bir hizmet ayarlarken ayarını değiştirebilirsiniz.

    ziyaret edin.
  5. Bitti'yi tıklayın.

ziyaret edin.

Cloud Firestore'u etkinleştirdiğinizde şurada da API etkinleştirilir: Cloud API Yöneticisi.

Geliştirme ortamınızı ayarlama

Gerekli bağımlılıkları ve istemci kitaplıklarını uygulamanıza ekleyin.

Web

  1. Talimatları uygulayarak Firebase'i web uygulamanıza ekleyin.
  2. Firebase ve Cloud Firestore kitaplıklarını uygulamanıza ekleyin:
    <script src="https://www.gstatic.com/firebasejs/10.12.3/firebase-app-compat.js"></script>
    <script src="https://www.gstatic.com/firebasejs/10.12.3/firebase-firestore-compat.js"></script>
    . Cloud Firestore SDK, npm paketi olarak da mevcuttur.
    npm install firebase@10.12.3 --save
    
    . Hem Firebase hem de Cloud Firestore'u manuel olarak zorunlu kılmanız gerekir.
    import firebase from "firebase/compat/app";
    // Required for side-effects
    import "firebase/firestore";
    

Web

  1. Talimatları uygulayarak Firebase'i web uygulamanıza ekleyin.
  2. Cloud Firestore SDK, npm paketi olarak sunulur.
    npm install firebase@10.12.3 --save
    
    . Hem Firebase'i hem de Cloud Firestore'u içe aktarmanız gerekir.
    import { initializeApp } from "firebase/app";
    import { getFirestore } from "firebase/firestore";
    
ziyaret edin.
iOS ve üzeri

Talimatları uygulayarak Firebase'i Apple uygulamanıza ekleyin.

Firebase bağımlılıklarını yükleyip yönetmek için Swift Package Manager'ı kullanın.

  1. Xcode'da, uygulama projeniz açıkken Dosya > Swift Paketleri > Paket Bağımlılığı Ekleyin.
  2. İstendiğinde Firebase Apple platformlar SDK deposunu ekleyin:
  3.   https://github.com/firebase/firebase-ios-sdk
      
    .
  4. Firestore kitaplığını seçin.
  5. İşlemi tamamladığınızda, Xcode otomatik olarak arka planda tutmalarını sağlar.
Android
  1. Talimatları uygulayarak Firebase'i Android uygulamanıza ekleyin.
  2. Her bir Firebase Android BoM, Android için Cloud Firestore kitaplığına yönelik bağımlılığı modülünüzün (uygulama düzeyinde) Gradle dosyanız (genellikle app/build.gradle.kts veya app/build.gradle).
    dependencies {
        // Import the BoM for the Firebase platform
        implementation(platform("com.google.firebase:firebase-bom:33.1.2"))
    
        // Declare the dependency for the Cloud Firestore library
        // When using the BoM, you don't specify versions in Firebase library dependencies
        implementation("com.google.firebase:firebase-firestore")
    }
    

    Şunu kullanarak: Firebase Android BoM, Uygulamanız her zaman Firebase Android'in uyumlu sürümlerini kullanır kitaplıklar.

    (Alternatif) Firebase kitaplığı bağımlılıklarını şu komutu kullanmadan bildirin: BoM

    Firebase BoM'yi kullanmamayı seçerseniz her bir Bağımlılık satırında Firebase kitaplık sürümü.

    Google Dokümanlar'da birden çok Firebase kitaplığı kullanıyorsanız kullanıyorsanız kitaplığı yönetmek için BoM'u kullanmanızı Bu da tüm sürümlerin uyumlu olmasını sağlar.

    dependencies {
        // Declare the dependency for the Cloud Firestore library
        // When NOT using the BoM, you must specify versions in Firebase library dependencies
        implementation("com.google.firebase:firebase-firestore:25.0.0")
    }
    

    Kotlin'e özel bir kitaplık modülü mü arıyorsunuz? Şununla başlamak: Ekim 2023 sürümü, Hem Kotlin hem de Java geliştiricileri, (ayrıntılar için bkz. bu girişimle ilgili SSS).

Dart

  1. Henüz yapmadıysanız yapılandırın ve Flutter uygulamanızda Firebase'i başlatın.
  2. Flutter projenizin kök dizininden aşağıdaki komutu çalıştırarak eklentiyi yükleyin:
    flutter pub add cloud_firestore
    .
  3. Ardından Flutter uygulamanızı yeniden derleyin:
    flutter run
    .
  4. İsteğe bağlı: iOS ve macOS derleme süreleri önceden derlenmiş bir çerçevedir.

    Şu anda iOS için Firestore SDK'sı, 5 dakikadan fazla zaman harcıyor. Derleme sürelerini kısaltmak için isterseniz, bu satırı şuraya ekleyerek önceden derlenmiş bir sürümü kullanabilirsiniz: Podfile dosyanızdaki target 'Runner' do bloğu:

    target 'Runner' do
      use_frameworks!
      use_modular_headers!
    
      pod 'FirebaseFirestore',
        :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git',
        :tag => 'IOS_SDK_VERSION'
    
      flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
      target 'RunnerTests' do
        inherit! :search_paths
      end
    end

    IOS_SDK_VERSION kısmını Firebase iOS sürümüyle değiştirin firebase_core firebase_sdk_version.rb dosyası olarak kaydedebilirsiniz. Tarayıcı uygulamasının en son sürümünü kullanmıyorsanız firebase_core, yerel Pub paketinizde bu dosyayı arayın önbellek (genellikle ~/.pub-cache).

    Ayrıca, CocoaPods'u 1.9.1 veya daha yüksek:

    gem install cocoapods

    Daha fazla bilgi için sorun bulabilirsiniz.

Java
  1. Firebase Admin SDK'sını uygulamanıza ekleyin:
    • Gradle kullanarak:
      compile 'com.google.firebase:firebase-admin:1.32.0'
      
    • Maven'i kullanarak:
      <dependency>
        <groupId>com.google.firebase</groupId>
        <artifactId>firebase-admin</artifactId>
        <version>1.32.0</version>
      </dependency>
           
  2. Cloud Firestore'u başlatmak için aşağıdaki talimatları uygulayın doğru kimlik bilgilerine sahip olmanız gerekir.
Python
  1. Firebase Admin SDK'yı Python uygulamanıza ekleyin:
    pip install --upgrade firebase-admin
    .
  2. Cloud Firestore'u başlatmak için aşağıdaki talimatları uygulayın doğru kimlik bilgilerine sahip olmanız gerekir.
C++
  1. Talimatları uygulayarak Firebase'i C++ projenize ekleyin.
  2. Android için C++ arayüzü.
    • Bağımlılıkları kademeli olarak artırın. Modülünüze aşağıdakileri ekleyin (uygulama düzeyinde) Gradle dosyası (genellikle app/build.gradle):
              android.defaultConfig.externalNativeBuild.cmake {
                arguments "-DFIREBASE_CPP_SDK_DIR=$gradle.firebase_cpp_sdk_dir"
              }
      
              apply from: "$gradle.firebase_cpp_sdk_dir/Android/firebase_dependencies.gradle"
              firebaseCpp.dependencies {
                // earlier entries
                auth
                firestore
              }
              
    • İkili bağımlılıklar. Aynı şekilde ikili bağımlılıklar, CMakeLists.txt dosyanıza aşağıdakini eklemektir: dosya:
              add_subdirectory(${FIREBASE_CPP_SDK_DIR} bin/ EXCLUDE_FROM_ALL)
              set(firebase_libs firebase_auth firebase_firestore firebase_app)
              # Replace the target name below with the actual name of your target,
              # for example, "native-lib".
              target_link_libraries(${YOUR_TARGET_NAME_HERE} "${firebase_libs}")
              
  3. Masaüstü entegrasyonunu ayarlamak için Firebase'i C++ projenize ekleme bölümüne bakın.
Unity
  1. Talimatları uygulayarak Firebase'i Unity'nize ekleyin inceleyebilirsiniz.
  2. Projenizi Android derlemelerini küçültecek şekilde yapılandırmak için Unity arayüzünü kullanın.
  3. Error while merging dex archives mesajından kaçınmak için derlemeyi küçültmeniz gerekir.

    • Bu seçeneği Oyuncu Ayarları > Android > Yayınlanıyor Ayarlar > Küçült.
    • Seçenekler Unity'nin farklı sürümlerinde değişiklik gösterebilir, bu nedenle resmi Unity belgelerini Firebase Unity Derlemesi Hata Ayıklama Kılavuzu.
    • Küçültme etkinleştirildikten sonra başvurulan yöntemlerin sayısı hâlâ görünüyorsa sınırı aşmışsa diğer bir seçenek de multidex öğesini şu şekilde etkinleştirmektir:
      • Oynatıcı Ayarları altındaki Özel Gradle Şablonu etkinse mainTemplate.gradle
      • veya dışa aktarılan projeyi oluşturmak için Android Studio kullanıyorsanız modül düzeyindeki build.gradle dosyası.
Node.js
  1. Firebase Admin SDK'sını uygulamanıza ekleyin:
    npm install firebase-admin --save
    .
  2. Cloud Firestore'u başlatmak için aşağıdaki talimatları uygulayın doğru kimlik bilgilerine sahip olmanız gerekir.
Go
  1. Firebase Admin SDK'sını Go uygulamanıza ekleyin:
    go get firebase.google.com/go
    
    .
  2. Cloud Firestore'u başlatmak için aşağıdaki talimatları uygulayın doğru kimlik bilgilerine sahip olmanız gerekir.
PHP
  1. Cloud Firestore sunucusu istemci kitaplıkları (Java, Node.js, Python, Go, PHP, C# ve Ruby) kullanımı Google Uygulaması Varsayılan Kimlik Bilgileri kimlik doğrulama için
    • Geliştirme ortamınızdan kimlik doğrulamak için GOOGLE_APPLICATION_CREDENTIALS ortam değişkenini bir JSON hizmet hesabı anahtar dosyasına işaret edecek şekilde ayarlayın. Anahtar dosyası oluşturabilirsiniz (API Konsolu Kimlik Bilgileri sayfasında).
      export GOOGLE_APPLICATION_CREDENTIALS="path/to/your/keyfile.json"
    • Uygulamanızı çalıştırıyorsanız üretim ortamınızda kimlik doğrulaması yapmanız gerekmez. Cloud Firestore için kullandığınız projeyi kullanarak bunu App Engine veya Compute Engine üzerinde uygulayabilirsiniz. Aksi halde hizmet hesabı oluşturun.
  2. gRPC uzantısını yükleme ve etkinleştirme (istemci kitaplığını kullanmanız gerekir).
  3. Cloud Firestore PHP kitaplığını uygulamanıza ekleyin:
    composer require google/cloud-firestore
    .
C#
  1. Cloud Firestore sunucusu istemci kitaplıkları (Java, Node.js, Python, Go, PHP, C# ve Ruby) kullanımı Google Uygulaması Varsayılan Kimlik Bilgileri kimlik doğrulama için
    • Geliştirme ortamınızdan kimlik doğrulamak için GOOGLE_APPLICATION_CREDENTIALS ortam değişkenini bir JSON hizmet hesabı anahtar dosyasına işaret edecek şekilde ayarlayın. Anahtar dosyası oluşturabilirsiniz (API Konsolu Kimlik Bilgileri sayfasında).
      export GOOGLE_APPLICATION_CREDENTIALS="path/to/your/keyfile.json"
    • Uygulamanızı çalıştırıyorsanız üretim ortamınızda kimlik doğrulaması yapmanız gerekmez. Cloud Firestore için kullandığınız projeyi kullanarak bunu App Engine veya Compute Engine üzerinde uygulayabilirsiniz. Aksi halde hizmet hesabı oluşturun.
  2. .csproj dosyanızdaki uygulamanıza Cloud Firestore C# kitaplığını ekleyin:
    <ItemGroup>
      <PackageReference Include="Google.Cloud.Firestore" Version="1.1.0-beta01" />
    </ItemGroup>
  3. Program.cs dosyanıza aşağıdakileri ekleyin:
    using Google.Cloud.Firestore;
Ruby
  1. Cloud Firestore sunucusu istemci kitaplıkları (Java, Node.js, Python, Go, PHP, C# ve Ruby) kullanımı Google Uygulaması Varsayılan Kimlik Bilgileri kimlik doğrulama için
    • Geliştirme ortamınızdan kimlik doğrulamak için GOOGLE_APPLICATION_CREDENTIALS ortam değişkenini bir JSON hizmet hesabı anahtar dosyasına işaret edecek şekilde ayarlayın. Anahtar dosyası oluşturabilirsiniz (API Konsolu Kimlik Bilgileri sayfasında).
      export GOOGLE_APPLICATION_CREDENTIALS="path/to/your/keyfile.json"
    • Uygulamanızı çalıştırıyorsanız üretim ortamınızda kimlik doğrulaması yapmanız gerekmez. Cloud Firestore için kullandığınız projeyi kullanarak bunu App Engine veya Compute Engine üzerinde uygulayabilirsiniz. Aksi halde hizmet hesabı oluşturun.
  2. Cloud Firestore Ruby kitaplığını Gemfile cihazınızdaki uygulamanıza ekleyin:
    gem "google-cloud-firestore"
  3. Bağımlılıkları Gemfile dosyanızdaki şu komutu kullanarak yükleyin:
    bundle install

(İsteğe bağlı) Firebase Local Emulator Suite ile prototip oluşturun ve test edin

Mobil uygulama geliştiricilerin, uygulamanızın yazma ve okuma bilgilerinden bahsetmeden önce: Şimdi de Cloud Firestore'dan yeni oyununuzun prototipini oluşturun ve Cloud Firestore işlevini test edin: Firebase Local Emulator Suite. Farklı veri modellerini deniyorsanız veya en uygun maliyetli yolu bulmaya çalışma arka uçla etkileşime girin. Arka uçla etkileşime girmeden yerel olarak çalışabilme çok iyi bir fikir olabilir.

Cloud Firestore emülatörü, Yerel Emulator Suite'in bir parçasıdır. uygulamanızın emüle edilmiş veritabanı içeriğinizle ve yapılandırmanızla etkileşim kurmasına olanak tanır. ve isteğe bağlı olarak emüle edilen proje kaynaklarınızın (işlevler, diğer veritabanları ve güvenlik kuralları) ekleyin.

Cloud Firestore emülatörünü kullanmak için birkaç adım yeterlidir:

  1. Emülatöre bağlanmak için uygulamanızın test yapılandırmasına bir kod satırı ekleme.
  2. Yerel proje dizininizin kök dizininden firebase emulators:start komutunu çalıştırın.
  3. Bir Cloud Firestore platformu kullanarak uygulamanızın prototip kodundan çağrı yapma SDK her zamanki gibi.

Cloud Firestore ve Cloud Functions'ı içeren ayrıntılı bir adım adım açıklamalı kılavuz mevcuttur. Ayrıca Local Emulator Suite tanıtımı'na da göz atmalısınız.

Cloud Firestore'u ilk kullanıma hazırlama

Bir Cloud Firestore örneğini başlatın:

Web

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 öğesini web uygulamanızın firebaseConfig.

Cihazın bağlantısı kesildiğinde verileri saklamak için Çevrimdışı Verileri Etkinleştirme dokümanlarına bakın.

Web

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 öğesini web uygulamanızın firebaseConfig.

Cihazın bağlantısı kesildiğinde verileri saklamak için Çevrimdışı Verileri Etkinleştirme dokümanlarına bakın.

Hızlı
Not: Bu ürün, watchOS ve App Clip hedeflerinde kullanılamaz.
import FirebaseCore
import FirebaseFirestore
FirebaseApp.configure()

let db = Firestore.firestore()
Hedef-C
Not: Bu ürün, watchOS ve App Clip hedeflerinde kullanılamaz.
@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;
Java
Cloud Firestore SDK'sı bağlı olarak farklı şekillerde başlatılır. size yardımcı olur. En yaygın yöntemler aşağıda verilmiştir. Eksiksiz bir referans için bkz. Başlat Yönetici SDK'si ekleyin.
  • Google Cloud'da ilk kullanıma hazırlama
    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();
    
  • Kendi sunucunuzda ilk kullanıma hazırlama

    Firebase Admin SDK'yı kendi sunucunuzda kullanmak için hizmet hesabına sahip e-posta adresleriniz.

    Git IAM ve yönetici > Hizmet hesapları kullanıma sunduk. Yeni bir özel anahtar oluşturun ve JSON'u kaydedin dosyası olarak kaydedebilirsiniz. Ardından bu dosyayı kullanarak SDK'yı başlatın:

    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();
    
  • Python
    Cloud Firestore SDK'sı bağlı olarak farklı şekillerde başlatılır. size yardımcı olur. En yaygın yöntemler aşağıda verilmiştir. Eksiksiz bir referans için bkz. Başlat Yönetici SDK'si ekleyin.
  • Google Cloud'da ilk kullanıma hazırlama
    import firebase_admin
    from firebase_admin import firestore
    
    # Application Default credentials are automatically created.
    app = firebase_admin.initialize_app()
    db = firestore.client()

    SDK'yı başlatmak için mevcut bir uygulama varsayılan kimlik bilgisi de kullanılabilir.

    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()
  • Kendi sunucunuzda ilk kullanıma hazırlama

    Firebase Admin SDK'yı kendi sunucunuzda kullanmak için hizmet hesabına sahip e-posta adresleriniz.

    Git IAM ve yönetici > Hizmet hesapları kullanıma sunduk. Yeni bir özel anahtar oluşturun ve JSON'u kaydedin dosyası olarak kaydedebilirsiniz. Ardından bu dosyayı kullanarak SDK'yı başlatın:

    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'sı bağlı olarak farklı şekillerde başlatılır. size yardımcı olur. En yaygın yöntemler aşağıda verilmiştir. Eksiksiz bir referans için bkz. Başlat Yönetici SDK'si ekleyin.
  • Google Cloud'da ilk kullanıma hazırlama
    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'yı başlatmak için mevcut bir uygulama varsayılan kimlik bilgisi de kullanılabilir.

    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()
  • Kendi sunucunuzda ilk kullanıma hazırlama

    Firebase Admin SDK'yı kendi sunucunuzda kullanmak için hizmet hesabına sahip e-posta adresleriniz.

    Git IAM ve yönetici > Hizmet hesapları kullanıma sunduk. Yeni bir özel anahtar oluşturun ve JSON'u kaydedin dosyası olarak kaydedebilirsiniz. Ardından bu dosyayı kullanarak SDK'yı başlatın:

    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'sı bağlı olarak farklı şekillerde başlatılır. size yardımcı olur. En yaygın yöntemler aşağıda verilmiştir. Eksiksiz bir referans için bkz. Başlat Yönetici SDK'si ekleyin.
    • Cloud Functions'da ilk kullanıma hazırlama
      const { initializeApp, applicationDefault, cert } = require('firebase-admin/app');
      const { getFirestore, Timestamp, FieldValue, Filter } = require('firebase-admin/firestore');
      initializeApp();
      
      const db = getFirestore();
      
    • Google Cloud'da ilk kullanıma hazırlama
      const { initializeApp, applicationDefault, cert } = require('firebase-admin/app');
      const { getFirestore, Timestamp, FieldValue, Filter } = require('firebase-admin/firestore');
      initializeApp({
        credential: applicationDefault()
      });
      
      const db = getFirestore();
    • Kendi sunucunuzda ilk kullanıma hazırlama

      Firebase Admin SDK'yı kendi sunucunuzda (veya başka herhangi bir Node.js ortamında) kullanmak için: hizmet hesabı kullanmanız gerekir. IAM ve yönetici > Hizmet hesapları'nı tıklayın. Yeni bir özel anahtar oluşturun ve JSON dosyasını kaydedin. Ardından bu dosyayı kullanarak SDK'yı başlatın:

      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();
      
    Go
    Cloud Firestore SDK'sı bağlı olarak farklı şekillerde başlatılır. size yardımcı olur. En yaygın yöntemler aşağıda verilmiştir. Eksiksiz bir referans için bkz. Başlat Yönetici SDK'si ekleyin.
  • Google Cloud'da ilk kullanıma hazırlama
    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()
    
  • Kendi sunucunuzda ilk kullanıma hazırlama

    Firebase Admin SDK'yı kendi sunucunuzda kullanmak için hizmet hesabına sahip e-posta adresleriniz.

    Git IAM ve yönetici > Hizmet hesapları kullanıma sunduk. Yeni bir özel anahtar oluşturun ve JSON'u kaydedin dosyası olarak kaydedebilirsiniz. Ardından bu dosyayı kullanarak SDK'yı başlatın:

    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()
    
  • PHP

    PHP

    Cloud Firestore istemcisi yükleme ve oluşturma hakkında daha fazla bilgi için Cloud Firestore İstemci Kitaplıkları.

    use Google\Cloud\Firestore\FirestoreClient;
    
    /**
     * Initialize Cloud Firestore with default project ID.
     */
    function setup_client_create(string $projectId = null)
    {
        // Create the Cloud Firestore client
        if (empty($projectId)) {
            // The `projectId` parameter is optional and represents which project the
            // client will act on behalf of. If not supplied, the client falls back to
            // the default project inferred from the environment.
            $db = new FirestoreClient();
            printf('Created Cloud Firestore client with default project ID.' . PHP_EOL);
        } else {
            $db = new FirestoreClient([
                'projectId' => $projectId,
            ]);
            printf('Created Cloud Firestore client with project ID: %s' . PHP_EOL, $projectId);
        }
    }
    Unity
    using Firebase.Firestore;
    using Firebase.Extensions;
    FirebaseFirestore db = FirebaseFirestore.DefaultInstance;
    C#

    C#

    Cloud Firestore istemcisi yükleme ve oluşturma hakkında daha fazla bilgi için Cloud Firestore İstemci Kitaplıkları.

    FirestoreDb db = FirestoreDb.Create(project);
    Console.WriteLine("Created Cloud Firestore client with project ID: {0}", project);
    Ruby
    require "google/cloud/firestore"
    
    # The `project_id` parameter is optional and represents which project the
    # client will act on behalf of. If not supplied, the client falls back to the
    # default project inferred from the environment.
    firestore = Google::Cloud::Firestore.new project_id: project_id
    
    puts "Created Cloud Firestore client with given project ID."

    Veri ekle

    Cloud Firestore, verileri Belgeler'de depolar ve bu veriler Koleksiyonlar'da depolanır. Cloud Firestore, koleksiyonları ve belgeleri dolaylı yoldan oluşturur ilk kez veri eklediğinizde. Açık bir şekilde oluşturmanız gerekmez, koleksiyonlar veya dokümanlar oluşturabilirsiniz.

    Aşağıdaki örnek kodu kullanarak yeni bir koleksiyon ve doküman oluşturun.

    Web

    import { collection, addDoc } from "firebase/firestore"; 
    
    try {
      const docRef = await addDoc(collection(db, "users"), {
        first: "Ada",
        last: "Lovelace",
        born: 1815
      });
      console.log("Document written with ID: ", docRef.id);
    } catch (e) {
      console.error("Error adding document: ", e);
    }

    Web

    db.collection("users").add({
        first: "Ada",
        last: "Lovelace",
        born: 1815
    })
    .then((docRef) => {
        console.log("Document written with ID: ", docRef.id);
    })
    .catch((error) => {
        console.error("Error adding document: ", error);
    });
    Swift
    Not: Bu ürün, watchOS ve App Clip hedeflerinde kullanılamaz.
    // Add a new document with a generated ID
    do {
      let ref = try await db.collection("users").addDocument(data: [
        "first": "Ada",
        "last": "Lovelace",
        "born": 1815
      ])
      print("Document added with ID: \(ref.documentID)")
    } catch {
      print("Error adding document: \(error)")
    }
    Objective-C
    Not: Bu ürün, watchOS ve App Clip hedeflerinde kullanılamaz.
    // Add a new document with a generated ID
    __block FIRDocumentReference *ref =
        [[self.db collectionWithPath:@"users"] addDocumentWithData:@{
          @"first": @"Ada",
          @"last": @"Lovelace",
          @"born": @1815
        } completion:^(NSError * _Nullable error) {
          if (error != nil) {
            NSLog(@"Error adding document: %@", error);
          } else {
            NSLog(@"Document added with ID: %@", ref.documentID);
          }
        }];

    Kotlin+KTX

    // Create a new user with a first and last name
    val user = hashMapOf(
        "first" to "Ada",
        "last" to "Lovelace",
        "born" to 1815,
    )
    
    // Add a new document with a generated ID
    db.collection("users")
        .add(user)
        .addOnSuccessListener { documentReference ->
            Log.d(TAG, "DocumentSnapshot added with ID: ${documentReference.id}")
        }
        .addOnFailureListener { e ->
            Log.w(TAG, "Error adding document", e)
        }

    Java

    // Create a new user with a first and last name
    Map<String, Object> user = new HashMap<>();
    user.put("first", "Ada");
    user.put("last", "Lovelace");
    user.put("born", 1815);
    
    // Add a new document with a generated ID
    db.collection("users")
            .add(user)
            .addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
                @Override
                public void onSuccess(DocumentReference documentReference) {
                    Log.d(TAG, "DocumentSnapshot added with ID: " + documentReference.getId());
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Log.w(TAG, "Error adding document", e);
                }
            });

    Dart

    // Create a new user with a first and last name
    final user = <String, dynamic>{
      "first": "Ada",
      "last": "Lovelace",
      "born": 1815
    };
    
    // Add a new document with a generated ID
    db.collection("users").add(user).then((DocumentReference doc) =>
        print('DocumentSnapshot added with ID: ${doc.id}'));
    Java
    DocumentReference docRef = db.collection("users").document("alovelace");
    // Add document data  with id "alovelace" using a hashmap
    Map<String, Object> data = new HashMap<>();
    data.put("first", "Ada");
    data.put("last", "Lovelace");
    data.put("born", 1815);
    //asynchronously write data
    ApiFuture<WriteResult> result = docRef.set(data);
    // ...
    // result.get() blocks on response
    System.out.println("Update time : " + result.get().getUpdateTime());
    Python
    doc_ref = db.collection("users").document("alovelace")
    doc_ref.set({"first": "Ada", "last": "Lovelace", "born": 1815})

    Python

    doc_ref = db.collection("users").document("alovelace")
    await doc_ref.set({"first": "Ada", "last": "Lovelace", "born": 1815})
    C++
    // Add a new document with a generated ID
    Future<DocumentReference> user_ref =
        db->Collection("users").Add({{"first", FieldValue::String("Ada")},
                                     {"last", FieldValue::String("Lovelace")},
                                     {"born", FieldValue::Integer(1815)}});
    
    user_ref.OnCompletion([](const Future<DocumentReference>& future) {
      if (future.error() == Error::kErrorOk) {
        std::cout << "DocumentSnapshot added with ID: " << future.result()->id()
                  << std::endl;
      } else {
        std::cout << "Error adding document: " << future.error_message() << std::endl;
      }
    });
    Node.js
    const docRef = db.collection('users').doc('alovelace');
    
    await docRef.set({
      first: 'Ada',
      last: 'Lovelace',
      born: 1815
    });
    Go
    _, _, err := client.Collection("users").Add(ctx, map[string]interface{}{
    	"first": "Ada",
    	"last":  "Lovelace",
    	"born":  1815,
    })
    if err != nil {
    	log.Fatalf("Failed adding alovelace: %v", err)
    }
    PHP

    PHP

    Cloud Firestore istemcisi yükleme ve oluşturma hakkında daha fazla bilgi için Cloud Firestore İstemci Kitaplıkları.

    $docRef = $db->collection('samples/php/users')->document('alovelace');
    $docRef->set([
        'first' => 'Ada',
        'last' => 'Lovelace',
        'born' => 1815
    ]);
    printf('Added data to the lovelace document in the users collection.' . PHP_EOL);
    Unity
    DocumentReference docRef = db.Collection("users").Document("alovelace");
    Dictionary<string, object> user = new Dictionary<string, object>
    {
    	{ "First", "Ada" },
    	{ "Last", "Lovelace" },
    	{ "Born", 1815 },
    };
    docRef.SetAsync(user).ContinueWithOnMainThread(task => {
    	Debug.Log("Added data to the alovelace document in the users collection.");
    });
    C#
    DocumentReference docRef = db.Collection("users").Document("alovelace");
    Dictionary<string, object> user = new Dictionary<string, object>
    {
        { "First", "Ada" },
        { "Last", "Lovelace" },
        { "Born", 1815 }
    };
    await docRef.SetAsync(user);
    Ruby
    doc_ref = firestore.doc "#{collection_path}/alovelace"
    
    doc_ref.set(
      {
        first: "Ada",
        last:  "Lovelace",
        born:  1815
      }
    )
    
    puts "Added data to the alovelace document in the users collection."

    Şimdi users koleksiyonuna başka bir doküman ekleyin. Bu dokümanın ilk listede görünmeyen bir anahtar/değer çiftini (ikinci ad) içeriyorsa uygulayacaksınız. Koleksiyondaki dokümanlar farklı bilgi grupları içerebilir.

    Web

    // Add a second document with a generated ID.
    import { addDoc, collection } from "firebase/firestore"; 
    
    try {
      const docRef = await addDoc(collection(db, "users"), {
        first: "Alan",
        middle: "Mathison",
        last: "Turing",
        born: 1912
      });
    
      console.log("Document written with ID: ", docRef.id);
    } catch (e) {
      console.error("Error adding document: ", e);
    }

    Web

    // Add a second document with a generated ID.
    db.collection("users").add({
        first: "Alan",
        middle: "Mathison",
        last: "Turing",
        born: 1912
    })
    .then((docRef) => {
        console.log("Document written with ID: ", docRef.id);
    })
    .catch((error) => {
        console.error("Error adding document: ", error);
    });
    Swift
    Not: Bu ürün, watchOS ve App Clip hedeflerinde kullanılamaz.
    // Add a second document with a generated ID.
    do {
      let ref = try await db.collection("users").addDocument(data: [
        "first": "Alan",
        "middle": "Mathison",
        "last": "Turing",
        "born": 1912
      ])
      print("Document added with ID: \(ref.documentID)")
    } catch {
      print("Error adding document: \(error)")
    }
    Objective-C
    Not: Bu ürün, watchOS ve App Clip hedeflerinde kullanılamaz.
    // Add a second document with a generated ID.
    __block FIRDocumentReference *ref =
        [[self.db collectionWithPath:@"users"] addDocumentWithData:@{
          @"first": @"Alan",
          @"middle": @"Mathison",
          @"last": @"Turing",
          @"born": @1912
        } completion:^(NSError * _Nullable error) {
          if (error != nil) {
            NSLog(@"Error adding document: %@", error);
          } else {
            NSLog(@"Document added with ID: %@", ref.documentID);
          }
        }];

    Kotlin+KTX

    // Create a new user with a first, middle, and last name
    val user = hashMapOf(
        "first" to "Alan",
        "middle" to "Mathison",
        "last" to "Turing",
        "born" to 1912,
    )
    
    // Add a new document with a generated ID
    db.collection("users")
        .add(user)
        .addOnSuccessListener { documentReference ->
            Log.d(TAG, "DocumentSnapshot added with ID: ${documentReference.id}")
        }
        .addOnFailureListener { e ->
            Log.w(TAG, "Error adding document", e)
        }

    Java

    // Create a new user with a first, middle, and last name
    Map<String, Object> user = new HashMap<>();
    user.put("first", "Alan");
    user.put("middle", "Mathison");
    user.put("last", "Turing");
    user.put("born", 1912);
    
    // Add a new document with a generated ID
    db.collection("users")
            .add(user)
            .addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
                @Override
                public void onSuccess(DocumentReference documentReference) {
                    Log.d(TAG, "DocumentSnapshot added with ID: " + documentReference.getId());
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Log.w(TAG, "Error adding document", e);
                }
            });

    Dart

    // Create a new user with a first and last name
    final user = <String, dynamic>{
      "first": "Alan",
      "middle": "Mathison",
      "last": "Turing",
      "born": 1912
    };
    
    // Add a new document with a generated ID
    db.collection("users").add(user).then((DocumentReference doc) =>
        print('DocumentSnapshot added with ID: ${doc.id}'));
    Java
    DocumentReference docRef = db.collection("users").document("aturing");
    // Add document data with an additional field ("middle")
    Map<String, Object> data = new HashMap<>();
    data.put("first", "Alan");
    data.put("middle", "Mathison");
    data.put("last", "Turing");
    data.put("born", 1912);
    
    ApiFuture<WriteResult> result = docRef.set(data);
    System.out.println("Update time : " + result.get().getUpdateTime());
    Python
    doc_ref = db.collection("users").document("aturing")
    doc_ref.set({"first": "Alan", "middle": "Mathison", "last": "Turing", "born": 1912})

    Python

    doc_ref = db.collection("users").document("aturing")
    await doc_ref.set(
        {"first": "Alan", "middle": "Mathison", "last": "Turing", "born": 1912}
    )
    C++
    db->Collection("users")
        .Add({{"first", FieldValue::String("Alan")},
              {"middle", FieldValue::String("Mathison")},
              {"last", FieldValue::String("Turing")},
              {"born", FieldValue::Integer(1912)}})
        .OnCompletion([](const Future<DocumentReference>& future) {
          if (future.error() == Error::kErrorOk) {
            std::cout << "DocumentSnapshot added with ID: "
                      << future.result()->id() << std::endl;
          } else {
            std::cout << "Error adding document: " << future.error_message()
                      << std::endl;
          }
        });
    Node.js
    const aTuringRef = db.collection('users').doc('aturing');
    
    await aTuringRef.set({
      'first': 'Alan',
      'middle': 'Mathison',
      'last': 'Turing',
      'born': 1912
    });
    Go
    _, _, err = client.Collection("users").Add(ctx, map[string]interface{}{
    	"first":  "Alan",
    	"middle": "Mathison",
    	"last":   "Turing",
    	"born":   1912,
    })
    if err != nil {
    	log.Fatalf("Failed adding aturing: %v", err)
    }
    PHP

    PHP

    Cloud Firestore istemcisi yükleme ve oluşturma hakkında daha fazla bilgi için Cloud Firestore İstemci Kitaplıkları.

    $docRef = $db->collection('samples/php/users')->document('aturing');
    $docRef->set([
        'first' => 'Alan',
        'middle' => 'Mathison',
        'last' => 'Turing',
        'born' => 1912
    ]);
    printf('Added data to the aturing document in the users collection.' . PHP_EOL);
    Unity
    DocumentReference docRef = db.Collection("users").Document("aturing");
    Dictionary<string, object> user = new Dictionary<string, object>
    {
    	{ "First", "Alan" },
    	{ "Middle", "Mathison" },
    	{ "Last", "Turing" },
    	{ "Born", 1912 }
    };
    docRef.SetAsync(user).ContinueWithOnMainThread(task => {
    	Debug.Log("Added data to the aturing document in the users collection.");
    });
    C#
    DocumentReference docRef = db.Collection("users").Document("aturing");
    Dictionary<string, object> user = new Dictionary<string, object>
    {
        { "First", "Alan" },
        { "Middle", "Mathison" },
        { "Last", "Turing" },
        { "Born", 1912 }
    };
    await docRef.SetAsync(user);
    Ruby
    doc_ref = firestore.doc "#{collection_path}/aturing"
    
    doc_ref.set(
      {
        first:  "Alan",
        middle: "Mathison",
        last:   "Turing",
        born:   1912
      }
    )
    
    puts "Added data to the aturing document in the users collection."

    Verileri okuma

    Verileri kullanma görüntüleyen Cloud Firestore'a veri eklediğinizi hızlıca doğrulamak için Firebase konsolunu kullanın.

    Ayrıca, yöntemini kullanın.

    Web

    import { collection, getDocs } from "firebase/firestore"; 
    
    const querySnapshot = await getDocs(collection(db, "users"));
    querySnapshot.forEach((doc) => {
      console.log(`${doc.id} => ${doc.data()}`);
    });

    Web

    db.collection("users").get().then((querySnapshot) => {
        querySnapshot.forEach((doc) => {
            console.log(`${doc.id} => ${doc.data()}`);
        });
    });
    Swift
    Not: Bu ürün, watchOS ve App Clip hedeflerinde kullanılamaz.
    do {
      let snapshot = try await db.collection("users").getDocuments()
      for document in snapshot.documents {
        print("\(document.documentID) => \(document.data())")
      }
    } catch {
      print("Error getting documents: \(error)")
    }
    Objective-C
    Not: Bu ürün, watchOS ve App Clip hedeflerinde kullanılamaz.
    [[self.db collectionWithPath:@"users"]
        getDocumentsWithCompletion:^(FIRQuerySnapshot * _Nullable snapshot,
                                     NSError * _Nullable 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("users")
        .get()
        .addOnSuccessListener { result ->
            for (document in result) {
                Log.d(TAG, "${document.id} => ${document.data}")
            }
        }
        .addOnFailureListener { exception ->
            Log.w(TAG, "Error getting documents.", exception)
        }

    Java

    db.collection("users")
            .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.w(TAG, "Error getting documents.", task.getException());
                    }
                }
            });

    Dart

    await db.collection("users").get().then((event) {
      for (var doc in event.docs) {
        print("${doc.id} => ${doc.data()}");
      }
    });
    Java
    // asynchronously retrieve all users
    ApiFuture<QuerySnapshot> query = db.collection("users").get();
    // ...
    // query.get() blocks on response
    QuerySnapshot querySnapshot = query.get();
    List<QueryDocumentSnapshot> documents = querySnapshot.getDocuments();
    for (QueryDocumentSnapshot document : documents) {
      System.out.println("User: " + document.getId());
      System.out.println("First: " + document.getString("first"));
      if (document.contains("middle")) {
        System.out.println("Middle: " + document.getString("middle"));
      }
      System.out.println("Last: " + document.getString("last"));
      System.out.println("Born: " + document.getLong("born"));
    }
    Python
    users_ref = db.collection("users")
    docs = users_ref.stream()
    
    for doc in docs:
        print(f"{doc.id} => {doc.to_dict()}")

    Python

    users_ref = db.collection("users")
    docs = users_ref.stream()
    
    async for doc in docs:
        print(f"{doc.id} => {doc.to_dict()}")
    C++
    Future<QuerySnapshot> users = db->Collection("users").Get();
    users.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
    const snapshot = await db.collection('users').get();
    snapshot.forEach((doc) => {
      console.log(doc.id, '=>', doc.data());
    });
    Go
    iter := client.Collection("users").Documents(ctx)
    for {
    	doc, err := iter.Next()
    	if err == iterator.Done {
    		break
    	}
    	if err != nil {
    		log.Fatalf("Failed to iterate: %v", err)
    	}
    	fmt.Println(doc.Data())
    }
    PHP

    PHP

    Cloud Firestore istemcisi yükleme ve oluşturma hakkında daha fazla bilgi için Cloud Firestore İstemci Kitaplıkları.

    $usersRef = $db->collection('samples/php/users');
    $snapshot = $usersRef->documents();
    foreach ($snapshot as $user) {
        printf('User: %s' . PHP_EOL, $user->id());
        printf('First: %s' . PHP_EOL, $user['first']);
        if (!empty($user['middle'])) {
            printf('Middle: %s' . PHP_EOL, $user['middle']);
        }
        printf('Last: %s' . PHP_EOL, $user['last']);
        printf('Born: %d' . PHP_EOL, $user['born']);
        printf(PHP_EOL);
    }
    printf('Retrieved and printed out all documents from the users collection.' . PHP_EOL);
    Unity
    CollectionReference usersRef = db.Collection("users");
    usersRef.GetSnapshotAsync().ContinueWithOnMainThread(task =>
    {
      QuerySnapshot snapshot = task.Result;
      foreach (DocumentSnapshot document in snapshot.Documents)
      {
        Debug.Log(String.Format("User: {0}", document.Id));
        Dictionary<string, object> documentDictionary = document.ToDictionary();
        Debug.Log(String.Format("First: {0}", documentDictionary["First"]));
        if (documentDictionary.ContainsKey("Middle"))
        {
          Debug.Log(String.Format("Middle: {0}", documentDictionary["Middle"]));
        }
    
        Debug.Log(String.Format("Last: {0}", documentDictionary["Last"]));
        Debug.Log(String.Format("Born: {0}", documentDictionary["Born"]));
      }
    
      Debug.Log("Read all data from the users collection.");
    });
    C#
    CollectionReference usersRef = db.Collection("users");
    QuerySnapshot snapshot = await usersRef.GetSnapshotAsync();
    foreach (DocumentSnapshot document in snapshot.Documents)
    {
        Console.WriteLine("User: {0}", document.Id);
        Dictionary<string, object> documentDictionary = document.ToDictionary();
        Console.WriteLine("First: {0}", documentDictionary["First"]);
        if (documentDictionary.ContainsKey("Middle"))
        {
            Console.WriteLine("Middle: {0}", documentDictionary["Middle"]);
        }
        Console.WriteLine("Last: {0}", documentDictionary["Last"]);
        Console.WriteLine("Born: {0}", documentDictionary["Born"]);
        Console.WriteLine();
    }
    Ruby
    users_ref = firestore.col collection_path
    users_ref.get do |user|
      puts "#{user.document_id} data: #{user.data}."
    end

    Verilerinizin güvenliğini sağlayın

    Web, Android veya Apple platformları SDK'sını kullanıyorsanız Firebase Authentication (Kimlik Doğrulaması) ve Verilerinizin güvenliğini sağlamak için Cloud Firestore Güvenlik Kuralları Cloud Firestore'a gidin.

    Başlamak için kullanabileceğiniz bazı temel kural gruplarını aşağıda bulabilirsiniz. Burada Kurallar sekme yardımcı oluyorum.

    Yetkilendirme gerekiyor

    // Allow read/write access to a document keyed by the user's UID
    service cloud.firestore {
      match /databases/{database}/documents {
        match /users/{uid} {
          allow read, write: if request.auth != null && request.auth.uid == uid;
        }
      }
    }
    

    Kilitli mod

    // Deny read/write access to all users under any conditions
    service cloud.firestore {
      match /databases/{database}/documents {
        match /{document=**} {
          allow read, write: if false;
        }
      }
    }
    

    Web, Android veya iOS uygulamanızı üretim kanalına dağıtmadan önce aşağıdaki adımları da uygulayın: kullanarak Cloud Firestore verilerinize yalnızca uygulama istemcilerinizin erişebilmesini sağlayın. Uygulama Kontrolü dokümanlarını inceleyin.

    Sunucu SDK'larından birini kullanıyorsanız Identity and Access Management (IAM) kullanarak veri güvenliğini sağlayın Cloud Firestore'da açabilirsiniz.

    Eğitim videosunu izleyin

    Cloud Firestore'u kullanmaya başlama hakkında ayrıntılı bilgi için aşağıdaki eğitim videolarından birini izleyin:

    Web
    iOS ve üzeri
    Android

    Firebase'de daha fazla video bulabilirsiniz YouTube kanalı.

    Sonraki adımlar

    Aşağıdaki konularla bilgilerinizi derinleştirin:

    • Codelabs: Aşağıdaki adımları izleyerek Cloud Firestore'u gerçek bir uygulamada kullanmayı öğrenin: Android, iOS veya Web.
    • Veri modeli: Verilerin nasıl olduğu hakkında daha fazla bilgi edinin. Cloud Firestore'da yapılandırılmıştır.
    • Veri ekleme: Cloud Firestore'da veri oluşturma ve güncelleme hakkında daha fazla bilgi edinin.
    • Verileri al: Verileri alma hakkında daha fazla bilgi edinin. dışı verilerdir.
    • Basit ve bileşik sorgular gerçekleştirme: Basit ve bileşik sorgular çalıştırmayı öğrenin.
    • Sorguları sıralama ve sınırlama Nasıl sipariş edeceğinizi öğrenin ve sorgularınızın döndürdüğü verileri sınırlamanız gerekir.