Cloud Firestore'u kullanmaya başlayın

Bu hızlı başlangıç ​​size Cloud Firestore'u nasıl kuracağınızı, veri ekleyeceğinizi ve ardından Firebase konsoluna yeni eklediğiniz verileri nasıl görüntüleyeceğinizi gösterir.

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 bir Firebase projesi oluşturmak veya Firebase hizmetlerini mevcut bir GCP projesine eklemek için ekrandaki talimatları izleyin.

  2. Firebase konsolunun Cloud Firestore bölümüne gidin. Mevcut bir Firebase projesini seçmeniz istenecektir. Veritabanı oluşturma iş akışını izleyin.

  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 iyidir ancak herkesin verilerinizi okumasına ve üzerine yazmasına olanak tanır. Testten sonra Verilerinizi güvence altına alın bölümünü incelediğinizden emin olun.

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

    Kilitli mod

    Mobil ve web istemcilerinden gelen 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) yine de veritabanınıza erişebilir.

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

    Başlangıçtaki Cloud Firestore Güvenlik Kuralları grubunuz, varsayılan Cloud Firestore veritabanınıza uygulanacaktır. 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 konumudur . Bu konumun, projenizde konum ayarı gerektiren GCP hizmetleri, özellikle de varsayılan Cloud Storage grubunuz ve App Engine uygulamanız (Cloud Scheduler kullanıyorsanız gereklidir) için kullanılacağını unutmayın.

    • Bir konum seçemiyorsanız projenizde zaten varsayılan bir GCP kaynak konumu vardır. Proje oluşturma sırasında veya konum ayarı gerektiren başka bir hizmetin kurulumu sırasında ayarlandı.

  5. Bitti'yi tıklayın.

Cloud Firestore'u etkinleştirdiğinizde, Cloud API Manager'daki API de etkinleştirilir.

Geliştirme ortamınızı ayarlayın

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

Web namespaced API

  1. Firebase'i Web uygulamanıza eklemek için talimatları izleyin.
  2. Firebase ve Cloud Firestore kitaplıklarını uygulamanıza ekleyin:
    <script src="https://www.gstatic.com/firebasejs/10.9.0/firebase-app-compat.js"></script>
    <script src="https://www.gstatic.com/firebasejs/10.9.0/firebase-firestore-compat.js"></script>
    Cloud Firestore SDK'sı aynı zamanda bir npm paketi olarak da mevcuttur.
    npm install firebase@10.9.0 --save
    
    Hem Firebase hem de Cloud Firestore'u manuel olarak zorunlu kılmanız gerekecektir.
    import firebase from "firebase/compat/app";
    // Required for side-effects
    import "firebase/firestore";
    

Web modular API

  1. Firebase'i Web uygulamanıza eklemek için talimatları izleyin.
  2. Cloud Firestore SDK'sı bir npm paketi olarak mevcuttur.
    npm install firebase@10.9.0 --save
    
    Hem Firebase'i hem de Cloud Firestore'u içe aktarmanız gerekecek.
    import { initializeApp } from "firebase/app";
    import { getFirestore } from "firebase/firestore";
    
iOS+

Firebase'i Apple uygulamanıza eklemek için talimatları izleyin.

Firebase bağımlılıklarını yüklemek ve yönetmek için Swift Paket Yöneticisini kullanın.

  1. Xcode'da, uygulama projeniz açıkken Dosya > Swift Paketleri > Paket Bağımlılığı Ekle seçeneğine gidin.
  2. İstendiğinde Firebase Apple platformları SDK deposunu ekleyin:
  3.   https://github.com/firebase/firebase-ios-sdk
      
  4. Firestore kitaplığını seçin.
  5. Bitirdiğinizde Xcode, bağımlılıklarınızı arka planda otomatik olarak çözmeye ve indirmeye başlayacaktır.
Android
  1. Firebase'i Android uygulamanıza eklemek için talimatları izleyin.
  2. Firebase Android BoM'yi kullanarak, modül (uygulama düzeyi) Gradle dosyanızda (genellikle app/build.gradle.kts veya app/build.gradle ) Android için Cloud Firestore kitaplığının bağımlılığını bildirin.
    dependencies {
        // Import the BoM for the Firebase platform
        implementation(platform("com.google.firebase:firebase-bom:32.7.4"))
    
        // 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")
    }
    

    Firebase Android BoM'yi kullandığınızda uygulamanız her zaman Firebase Android kitaplıklarının uyumlu sürümlerini kullanır.

    (Alternatif) BoM'yi kullanmadan Firebase kitaplığı bağımlılıklarını bildirin

    Firebase BoM'yi kullanmamayı tercih ederseniz her Firebase kitaplığı sürümünü bağımlılık satırında belirtmeniz gerekir.

    Uygulamanızda birden fazla Firebase kitaplığı kullanıyorsanız kitaplık sürümlerini yönetmek için tüm sürümlerin uyumlu olmasını sağlayan BoM'yi kullanmanızı önemle tavsiye ettiğimizi unutmayın.

    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:24.10.3")
    }
    

    Kotlin'e özgü bir kütüphane modülü mü arıyorsunuz? Ekim 2023 sürümünden itibaren hem Kotlin hem de Java geliştiricileri ana kitaplık modülüne güvenebilir (ayrıntılar için bu girişimle ilgili SSS bölümüne bakın).

Dart

  1. Henüz yapmadıysanız Flutter uygulamanızda Firebase'i yapılandırın ve başlatın .
  2. Eklentiyi yüklemek için Flutter projenizin kökünden aşağıdaki komutu çalıştırın:
    flutter pub add cloud_firestore
  3. Tamamlandığında Flutter uygulamanızı yeniden oluşturun:
    flutter run
  4. İsteğe bağlı: Önceden derlenmiş çerçeveyi dahil ederek iOS ve macOS derleme sürelerini iyileştirin.

    Şu anda iOS için Firestore SDK'sı, Xcode'da oluşturulması 5 dakikadan fazla sürebilen koda bağlıdır. Derleme sürelerini önemli ölçüde azaltmak için, bu satırı Pod dosyanızdaki target 'Runner' do bloğuna ekleyerek önceden derlenmiş bir sürümü kullanabilirsiniz:

    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 firebase_core firebase_sdk_version.rb dosyasında belirtilen Firebase iOS SDK sürümüyle değiştirin. firebase_core en son sürümünü kullanmıyorsanız, bu dosyayı yerel Pub paketi önbelleğinizde arayın (genellikle ~/.pub-cache ).

    Ayrıca CocoaPod'larınızı 1.9.1 veya daha yüksek bir sürüme yükselttiğinizden emin olun:

    gem install cocoapods

    Daha fazla bilgi için GitHub'daki soruna bakın.

Java
  1. Firebase Yönetici SDK'sını uygulamanıza ekleyin:
    • Gradle'ı Kullanma:
      compile 'com.google.firebase:firebase-admin:1.32.0'
      
    • Maven'i kullanma:
      <dependency>
        <groupId>com.google.firebase</groupId>
        <artifactId>firebase-admin</artifactId>
        <version>1.32.0</version>
      </dependency>
           
  2. Cloud Firestore'u ortamınızdaki uygun kimlik bilgileriyle başlatmak için aşağıdaki talimatları izleyin.
Python
  1. Firebase Yönetici SDK'sını Python uygulamanıza ekleyin:
    pip install --upgrade firebase-admin
  2. Cloud Firestore'u ortamınızdaki uygun kimlik bilgileriyle başlatmak için aşağıdaki talimatları izleyin.
C++
  1. Firebase'i C++ projenize eklemek için talimatları izleyin.
  2. Android için C++ arayüzü.
    • Gradle bağımlılıkları. Aşağıdakileri modülünüzün (uygulama düzeyi) Gradle dosyasına ekleyin (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. Benzer şekilde, ikili bağımlılıkları almanın önerilen yolu CMakeLists.txt dosyanıza aşağıdakini eklemektir:
              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 bkz. C++ projenize Firebase ekleme .
Birlik
  1. Firebase'i Unity projenize eklemek için talimatları izleyin.
  2. Projenizi Android yapılarını küçültecek şekilde yapılandırmak için Unity arayüzünü kullanın.
  3. Error while merging dex archives mesajını önlemek için yapıyı küçültmelisiniz.

    • Bu seçeneği Oynatıcı Ayarları > Android > Yayınlama Ayarları > Küçült bölümünde bulabilirsiniz.
    • Seçenekler, Unity'nin farklı sürümlerinde farklılık gösterebilir; bu nedenle resmi Unity belgelerine ve Firebase Unity Derleme Hata Ayıklama Kılavuzu'na bakın.
    • Küçültme etkinleştirildikten sonra başvurulan yöntemlerin sayısı hâlâ sınırı aşıyorsa başka bir seçenek de multidex aşağıdakilerde etkinleştirmektir:
      • mainTemplate.gradle , Oynatıcı Ayarları altındaki Özel Gradle Şablonu etkinse
      • veya dışa aktarılan projeyi oluşturmak için Android Studio kullanıyorsanız modül düzeyinde build.gradle dosyası.
Node.js
  1. Firebase Yönetici SDK'sını uygulamanıza ekleyin:
    npm install firebase-admin --save
  2. Cloud Firestore'u ortamınızdaki uygun kimlik bilgileriyle başlatmak için aşağıdaki talimatları izleyin.
Gitmek
  1. Firebase Yönetici SDK'sını Go uygulamanıza ekleyin:
    go get firebase.google.com/go
    
  2. Cloud Firestore'u ortamınızdaki uygun kimlik bilgileriyle başlatmak için aşağıdaki talimatları izleyin.
PHP
  1. Cloud Firestore sunucusu istemci kitaplıkları (Java, Node.js, Python, Go, PHP, C# ve Ruby), kimlik doğrulama için Google Uygulaması Varsayılan Kimlik Bilgilerini kullanır.
    • Geliştirme ortamınızdan kimlik doğrulaması yapmak için GOOGLE_APPLICATION_CREDENTIALS ortam değişkenini bir JSON hizmet hesabı anahtar dosyasını işaret edecek şekilde ayarlayın. API Konsolu Kimlik Bilgileri sayfasında bir anahtar dosyası oluşturabilirsiniz.
      export GOOGLE_APPLICATION_CREDENTIALS="path/to/your/keyfile.json"
    • Üretim ortamınızda, uygulamanızı Cloud Firestore için kullandığınız projeyi kullanarak App Engine veya Compute Engine üzerinde çalıştırıyorsanız kimlik doğrulaması yapmanıza gerek yoktur. Aksi takdirde bir hizmet hesabı oluşturun .
  2. İstemci kitaplığını kullanmanız gereken PHP için gRPC uzantısını yükleyin ve etkinleştirin.
  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), kimlik doğrulama için Google Uygulaması Varsayılan Kimlik Bilgilerini kullanır.
    • Geliştirme ortamınızdan kimlik doğrulaması yapmak için GOOGLE_APPLICATION_CREDENTIALS ortam değişkenini bir JSON hizmet hesabı anahtar dosyasını işaret edecek şekilde ayarlayın. API Konsolu Kimlik Bilgileri sayfasında bir anahtar dosyası oluşturabilirsiniz.
      export GOOGLE_APPLICATION_CREDENTIALS="path/to/your/keyfile.json"
    • Üretim ortamınızda, uygulamanızı Cloud Firestore için kullandığınız projeyi kullanarak App Engine veya Compute Engine üzerinde çalıştırıyorsanız kimlik doğrulaması yapmanıza gerek yoktur. Aksi takdirde bir hizmet hesabı oluşturun .
  2. Cloud Firestore C# kitaplığını .csproj dosyanızdaki uygulamanıza ekleyin:
    <ItemGroup>
      <PackageReference Include="Google.Cloud.Firestore" Version="1.1.0-beta01" />
    </ItemGroup>
  3. Program.cs dosyanıza şunu ekleyin:
    using Google.Cloud.Firestore;
Yakut
  1. Cloud Firestore sunucusu istemci kitaplıkları (Java, Node.js, Python, Go, PHP, C# ve Ruby), kimlik doğrulama için Google Uygulaması Varsayılan Kimlik Bilgilerini kullanır.
    • Geliştirme ortamınızdan kimlik doğrulaması yapmak için GOOGLE_APPLICATION_CREDENTIALS ortam değişkenini bir JSON hizmet hesabı anahtar dosyasını işaret edecek şekilde ayarlayın. API Konsolu Kimlik Bilgileri sayfasında bir anahtar dosyası oluşturabilirsiniz.
      export GOOGLE_APPLICATION_CREDENTIALS="path/to/your/keyfile.json"
    • Üretim ortamınızda, uygulamanızı Cloud Firestore için kullandığınız projeyi kullanarak App Engine veya Compute Engine üzerinde çalıştırıyorsanız kimlik doğrulaması yapmanıza gerek yoktur. Aksi takdirde bir hizmet hesabı oluşturun .
  2. Cloud Firestore Ruby kitaplığını Gemfile uygulamanıza ekleyin:
    gem "google-cloud-firestore"
  3. Bağımlılıkları Gemfile şunu kullanarak yükleyin:
    bundle install

(İsteğe bağlı) Firebase Local Emulator Suite ile prototip yapın ve test edin

Mobil geliştiriciler için, uygulamanızın Cloud Firestore'a nasıl yazdığını ve buradan okuduğunu konuşmadan önce, Cloud Firestore işlevselliğini prototiplemek ve test etmek için kullanabileceğiniz bir dizi aracı tanıtalım: Firebase Local Emulator Suite. Farklı veri modelleri deniyorsanız, güvenlik kurallarınızı optimize ediyorsanız veya arka uçla etkileşim kurmanın en uygun maliyetli yolunu bulmaya çalışıyorsanız, canlı hizmetleri dağıtmadan yerel olarak çalışabilmek harika bir fikir olabilir.

Cloud Firestore öykünücüsü, uygulamanızın öykünülmüş veritabanı içeriğiniz ve yapılandırmanızın yanı sıra isteğe bağlı olarak öykünülmüş proje kaynaklarınızla (işlevler, diğer veritabanları ve güvenlik kuralları) etkileşim kurmasını sağlayan Local Emulator Suite'in bir parçasıdır.

Cloud Firestore öykünücüsünü kullanmak yalnızca birkaç adımı içerir:

  1. Öykünücüye bağlanmak için uygulamanızın test yapılandırmasına bir kod satırı ekleme.
  2. Yerel proje dizininizin kökünden, firebase emulators:start çalıştırılıyor.
  3. Her zamanki gibi Cloud Firestore platform SDK'sını kullanarak uygulamanızın prototip kodundan arama yapma.

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

Cloud Firestore'u Başlat

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

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 web uygulamanızın firebaseConfig değeriyle değiştirin.

Aygıtın bağlantısı kesildiğinde verilerin kalıcı olması için Çevrimdışı Verileri Etkinleştir belgelerine bakın.

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 web uygulamanızın firebaseConfig değeriyle değiştirin.

Aygıtın bağlantısı kesildiğinde verilerin kalıcı olması için Çevrimdışı Verileri Etkinleştir belgelerine bakın.

Süratli
Not: Bu ürün watchOS ve App Clip hedeflerinde mevcut değildir.
import FirebaseCore
import FirebaseFirestore
FirebaseApp.configure()

let db = Firestore.firestore()
Amaç-C
Not: Bu ürün watchOS ve App Clip hedeflerinde mevcut değildir.
@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, ortamınıza bağlı olarak farklı şekillerde başlatılır. Aşağıda en yaygın yöntemler bulunmaktadır. Tam bir referans için bkz. Yönetici SDK'sını Başlatma .
  • Google Cloud'da başlat
    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 başlatın

    Firebase Admin SDK'yı kendi sunucunuzda kullanmak için bir hizmet hesabı kullanın.

    Google Cloud konsolunda IAM ve yönetici > Hizmet hesapları'na gidin. Yeni bir özel anahtar oluşturun ve JSON dosyasını kaydedin. Ardından SDK'yı başlatmak için dosyayı kullanı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, ortamınıza bağlı olarak farklı şekillerde başlatılır. Aşağıda en yaygın yöntemler bulunmaktadır. Tam bir referans için bkz. Yönetici SDK'sını Başlatma .
  • Google Cloud'da başlat
    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 başlatın

    Firebase Admin SDK'yı kendi sunucunuzda kullanmak için bir hizmet hesabı kullanın.

    Google Cloud konsolunda IAM ve yönetici > Hizmet hesapları'na gidin. Yeni bir özel anahtar oluşturun ve JSON dosyasını kaydedin. Ardından SDK'yı başlatmak için dosyayı kullanı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, ortamınıza bağlı olarak farklı şekillerde başlatılır. Aşağıda en yaygın yöntemler bulunmaktadır. Tam bir referans için bkz. Yönetici SDK'sını Başlatma .
  • Google Cloud'da başlat
    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 başlatın

    Firebase Admin SDK'yı kendi sunucunuzda kullanmak için bir hizmet hesabı kullanın.

    Google Cloud konsolunda IAM ve yönetici > Hizmet hesapları'na gidin. Yeni bir özel anahtar oluşturun ve JSON dosyasını kaydedin. Ardından SDK'yı başlatmak için dosyayı kullanı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, ortamınıza bağlı olarak farklı şekillerde başlatılır. Aşağıda en yaygın yöntemler bulunmaktadır. Tam bir referans için bkz. Yönetici SDK'sını Başlatma .
    • Cloud Functions'ta Başlat
      const { initializeApp, applicationDefault, cert } = require('firebase-admin/app');
      const { getFirestore, Timestamp, FieldValue, Filter } = require('firebase-admin/firestore');
      initializeApp();
      
      const db = getFirestore();
      
    • Google Cloud'da başlat
      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 başlatın

      Firebase Yönetici SDK'sını kendi sunucunuzda (veya başka bir Node.js ortamında) kullanmak için bir hizmet hesabı kullanın. Google Cloud konsolunda IAM ve yönetici > Hizmet hesapları'na gidin. Yeni bir özel anahtar oluşturun ve JSON dosyasını kaydedin. Ardından SDK'yı başlatmak için dosyayı kullanı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();
      
    Gitmek
    Cloud Firestore SDK, ortamınıza bağlı olarak farklı şekillerde başlatılır. Aşağıda en yaygın yöntemler bulunmaktadır. Tam bir referans için bkz. Yönetici SDK'sını Başlatma .
  • Google Cloud'da başlat
    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 başlatın

    Firebase Admin SDK'yı kendi sunucunuzda kullanmak için bir hizmet hesabı kullanın.

    Google Cloud konsolunda IAM ve yönetici > Hizmet hesapları'na gidin. Yeni bir özel anahtar oluşturun ve JSON dosyasını kaydedin. Ardından SDK'yı başlatmak için dosyayı kullanı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 istemcisini yükleme ve oluşturma hakkında daha fazla bilgi için Cloud Firestore İstemci Kitaplıkları'na bakın.

    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);
        }
    }
    Birlik
    using Firebase.Firestore;
    using Firebase.Extensions;
    FirebaseFirestore db = FirebaseFirestore.DefaultInstance;
    C#

    C#

    Cloud Firestore istemcisini yükleme ve oluşturma hakkında daha fazla bilgi için Cloud Firestore İstemci Kitaplıkları'na bakın.

    FirestoreDb db = FirestoreDb.Create(project);
    Console.WriteLine("Created Cloud Firestore client with project ID: {0}", project);
    Yakut
    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 Koleksiyonlar'da saklanan Belgeler'de saklar. Cloud Firestore, belgeye ilk kez veri eklediğinizde örtülü olarak koleksiyonlar ve belgeler oluşturur. Açıkça koleksiyon veya belge oluşturmanıza gerek yoktur.

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

    Web modular API

    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 namespaced API

    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);
    });
    Süratli
    Not: Bu ürün watchOS ve App Clip hedeflerinde mevcut değildir.
    // 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)")
    }
    Amaç-C
    Not: Bu ürün watchOS ve App Clip hedeflerinde mevcut değildir.
    // 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
    });
    Gitmek
    _, _, 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 istemcisini yükleme ve oluşturma hakkında daha fazla bilgi için Cloud Firestore İstemci Kitaplıkları'na bakın.

    $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);
    Birlik
    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);
    Yakut
    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 belge ekleyin. Bu belgenin, ilk belgede görünmeyen bir anahtar/değer çifti (ikinci ad) içerdiğine dikkat edin. Bir koleksiyondaki belgeler farklı bilgi kümeleri içerebilir.

    Web modular API

    // 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 namespaced API

    // 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);
    });
    Süratli
    Not: Bu ürün watchOS ve App Clip hedeflerinde mevcut değildir.
    // 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)")
    }
    Amaç-C
    Not: Bu ürün watchOS ve App Clip hedeflerinde mevcut değildir.
    // 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
    });
    Gitmek
    _, _, 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 istemcisini yükleme ve oluşturma hakkında daha fazla bilgi için Cloud Firestore İstemci Kitaplıkları'na bakın.

    $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);
    Birlik
    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);
    Yakut
    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 oku

    Cloud Firestore'a veri eklediğinizi hızla doğrulamak için Firebase konsolundaki veri görüntüleyiciyi kullanın.

    Koleksiyonun tamamını almak için "get" yöntemini de kullanabilirsiniz.

    Web modular API

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

    Web namespaced API

    db.collection("users").get().then((querySnapshot) => {
        querySnapshot.forEach((doc) => {
            console.log(`${doc.id} => ${doc.data()}`);
        });
    });
    Süratli
    Not: Bu ürün watchOS ve App Clip hedeflerinde mevcut değildir.
    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)")
    }
    Amaç-C
    Not: Bu ürün watchOS ve App Clip hedeflerinde mevcut değildir.
    [[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());
    });
    Gitmek
    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 istemcisini yükleme ve oluşturma hakkında daha fazla bilgi için Cloud Firestore İstemci Kitaplıkları'na bakın.

    $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);
    Birlik
    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();
    }
    Yakut
    users_ref = firestore.col collection_path
    users_ref.get do |user|
      puts "#{user.document_id} data: #{user.data}."
    end

    Verilerinizi güvence altına alın

    Web, Android veya Apple platformları SDK'sını kullanıyorsanız Cloud Firestore'daki verilerinizin güvenliğini sağlamak için Firebase Authentication ve Cloud Firestore Güvenlik Kurallarını kullanın.

    Başlamak için kullanabileceğiniz bazı temel kural kümelerini burada bulabilirsiniz. Güvenlik kurallarınızı konsolun Kurallar sekmesinde değiştirebilirsiniz.

    Yetkilendirme gerekli

    // Allow read/write access on all documents to any user signed in to the application
    service cloud.firestore {
      match /databases/{database}/documents {
        match /{document=**} {
          allow read, write: if request.auth != null;
        }
      }
    }
    

    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;
        }
      }
    }
    

    Test modu

    // Allow read/write access to all users under any conditions
    // Warning: **NEVER** use this rule set in production; it allows
    // anyone to overwrite your entire database.
    service cloud.firestore {
      match /databases/{database}/documents {
        match /{document=**} {
          allow read, write: if true;
        }
      }
    }
    

    Web, Android veya iOS uygulamanızı üretime dağıtmadan önce Cloud Firestore verilerinize yalnızca uygulama istemcilerinizin erişebildiğinden emin olmak için gerekli adımları atın. Uygulama Kontrolü belgelerine bakın.

    Sunucu SDK'larından birini kullanıyorsanız Cloud Firestore'daki verilerinizin güvenliğini sağlamak için Kimlik ve Erişim Yönetimi'ni (IAM) kullanın.

    Bir video eğitimi izleyin

    Cloud Firestore mobil istemci kitaplıklarını kullanmaya başlama konusunda ayrıntılı rehberlik için aşağıdaki video eğitimlerinden birini izleyin:

    iOS+
    Android

    Firebase YouTube kanalında daha fazla video bulabilirsiniz.

    Sonraki adımlar

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

    • CodelabsAndroid , iOS veya Web için codelab'i takip ederek Cloud Firestore'u gerçek bir uygulamada kullanmayı öğrenin.
    • Veri modeli — Hiyerarşik veriler ve alt koleksiyonlar da dahil olmak üzere verilerin Cloud Firestore'da nasıl yapılandırıldığı hakkında daha fazla bilgi edinin.
    • Veri ekleme — Cloud Firestore'da veri oluşturma ve güncelleme hakkında daha fazla bilgi edinin.
    • Veri alma — Verilerin nasıl alınacağı hakkında daha fazla bilgi edinin.
    • Basit ve bileşik sorgular gerçekleştirin — Basit ve bileşik sorguların nasıl çalıştırılacağını öğrenin.
    • Sorguları sıralama ve sınırlama Sorgularınızın döndürdüğü verileri nasıl sıralayacağınızı ve sınırlandıracağınızı öğrenin.