了解 2023 年 Google I/O 大会上介绍的 Firebase 亮点。了解详情

Cloud Firestore'u kullanmaya başlayın

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

Cloud Firestore veritabanı oluşturun

  1. Henüz yapmadıysanız bir Firebase projesi oluşturun: Firebase konsolunda , Proje ekle 'yi tıklayın ve ardından bir Firebase projesi oluşturmak veya mevcut bir GCP projesine Firebase hizmetleri 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ı 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 iyidir, ancak herkesin verilerinizi okumasına ve üzerine yazmasına izin verir. Test ettikten sonra, Verilerinizi koruyun bölümünü incelediğinizden emin olun.

    Web, Apple platformları veya Android SDK ile çalışmaya 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.

  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 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 hizmet kurulurken ayarlanmıştır.

  5. Bitti'yi tıklayın.

Cloud Firestore'u etkinleştirdiğinizde, Cloud API Manager'da API'yi de etkinleştirir.

Geliştirme ortamınızı kurun

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/9.22.1/firebase-app-compat.js"></script>
    <script src="https://www.gstatic.com/firebasejs/9.22.1/firebase-firestore-compat.js"></script>
    Cloud Firestore SDK, bir npm paketi olarak da mevcuttur.
    npm install firebase@9.22.1 --save
    
    Hem Firebase hem de Cloud Firestore'a manuel olarak gereksinim duymanız gerekir.
    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, bir npm paketi olarak mevcuttur.
    npm install firebase@9.22.1 --save
    
    Hem Firebase'i hem de Cloud Firestore'u içe aktarmanız gerekir.
    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ı kurmak ve yönetmek için Swift Paket Yöneticisi'ni kullanın.

  1. Xcode'da uygulama projeniz açıkken File > Swift Packages > Add Package Dependency 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. Bittiğinde, Xcode otomatik olarak arka planda bağımlılıklarınızı çözmeye ve indirmeye başlayacaktır.

Kotlin+KTX

  1. Firebase'i Android uygulamanıza eklemek için talimatları uygulayın.
  2. Firebase Android BoM'yi kullanarak, modül (uygulama düzeyi) Gradle dosyanızda (genellikle app/build.gradle ) Cloud Firestore Android kitaplığının bağımlılığını bildirin.
    dependencies {
        // Import the BoM for the Firebase platform
        implementation platform('com.google.firebase:firebase-bom:32.1.0')
    
        // 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-ktx'
    }
    

    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 kullanmadan Firebase kitaplığı bağımlılıklarını bildirin

    Firebase BoM'yi kullanmamayı seçerseniz, her bir 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 ederiz.

    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-ktx:24.6.1'
    }
    

Java

  1. Firebase'i Android uygulamanıza eklemek için talimatları uygulayın.
  2. Firebase Android BoM'yi kullanarak, modül (uygulama düzeyi) Gradle dosyanızda (genellikle app/build.gradle ) Cloud Firestore Android kitaplığının bağımlılığını bildirin.
    dependencies {
        // Import the BoM for the Firebase platform
        implementation platform('com.google.firebase:firebase-bom:32.1.0')
    
        // 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 kullanmadan Firebase kitaplığı bağımlılıklarını bildirin

    Firebase BoM'yi kullanmamayı seçerseniz, her bir 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 ederiz.

    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.6.1'
    }
    

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 şu 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 oluşturma sürelerini iyileştirin.

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

    target 'Runner' do
      pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '8.15.0'
      # ...
    end

    Ek olarak, CocoaPod'ları 1.9.1 veya üstüne yükselttiğinizden emin olun:

    gem install cocoapods

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

java
  1. Firebase Admin SDK'yı 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ızda uygun kimlik bilgileriyle başlatmak için aşağıdaki talimatları izleyin.
Piton
  1. Firebase Admin SDK'yı Python uygulamanıza ekleyin:
    pip install --upgrade firebase-admin
  2. Cloud Firestore'u ortamınızda 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++ arabirimi.
    • Gradle bağımlılıkları. Aşağıdakileri modülünüze (uygulama düzeyinde) 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 şunu eklemenizdir:
              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 kurmak için bkz. Firebase'i C++ projenize ekleyin .
Birlik
  1. Firebase'i Unity projenize eklemek için talimatları izleyin.
  2. Android için birlik arayüzü.
  3. Android için derlerken, Android DEX sınırından kaçınmak için ProGuarding'i etkinleştirin. Bunu yapmak için Unity editöründe:

    1. Dosya > Yapı Ayarları'nı seçin
    2. 'Platform'u 'Android' olarak değiştirin ve 'Platformu Değiştir'i tıklayın
    3. 'Oyuncu Ayarları…' seçeneğini tıklayın
    4. Ana Unity kullanıcı arabiriminde, "Android için Ayarlar" altında, "Yayınlama Ayarları"nı seçin
    5. "Küçült" bölümünün altında, hem Yayınla hem de Hata Ayıklama ayarlarını "Yok"tan "ProGuard"a değiştirin
Node.js
  1. Firebase Admin SDK'yı uygulamanıza ekleyin:
    npm install firebase-admin --save
  2. Cloud Firestore'u ortamınızda uygun kimlik bilgileriyle başlatmak için aşağıdaki talimatları izleyin.
Gitmek
  1. Firebase Admin SDK'yı Go uygulamanıza ekleyin:
    go get firebase.google.com/go
    
  2. Cloud Firestore'u ortamınızda 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ına 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ırsanız kimlik doğrulaması yapmanız gerekmez. Aksi takdirde, bir hizmet hesabı oluşturun .
  2. İstemci kitaplığını kullanmanız için ihtiyaç duyacağınız PHP için gRPC uzantısını kurun 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ına 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ırsanız kimlik doğrulaması yapmanız gerekmez. Aksi takdirde, bir 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 ş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ına 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ırsanız kimlik doğrulaması yapmanız gerekmez. 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 dosyanızdan şunu kullanarak kurun:
    bundle install

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

Mobil geliştiriciler için, uygulamanızın Cloud Firestore'a nasıl yazdığı ve Cloud Firestore'dan nasıl okuduğu hakkında konuşmadan önce, Cloud Firestore işlevinin prototipini oluşturmak ve test etmek için kullanabileceğiniz bir dizi aracı tanıtalım: Firebase Local Emulator Suite. Farklı veri modelleri deniyor, güvenlik kurallarınızı optimize ediyor 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ünmüş 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, çalıştırılan firebase emulators:start .
  3. Her zamanki gibi bir Cloud Firestore platform SDK'sı kullanarak uygulamanızın prototip kodundan çağrı yapma.

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

Cloud Firestore'u Başlatın

Bir Cloud Firestore örneği 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 ile değiştirin.

Cihaz bağlantısını kaybettiğinde verileri devam ettirmek 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 ile değiştirin.

Cihaz bağlantısını kaybettiğinde verileri devam ettirmek 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. Eksiksiz bir başvuru için bkz. Admin SDK'yı Başlatın .
  • Google Cloud
    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();
    
    başlat
  • 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();
    
  • Piton
    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. Eksiksiz bir başvuru için bkz. Admin SDK'yı Başlatın .
  • Google Cloud
    import firebase_admin
    from firebase_admin import firestore
    
    # Application Default credentials are automatically created.
    app = firebase_admin.initialize_app()
    db = firestore.client()
    başlat

    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. Eksiksiz bir başvuru için bkz. Admin SDK'yı Başlatın .
  • Google Cloud
    import firebase_admin
    from firebase_admin import firestore_async
    
    # Application Default credentials are automatically created.
    app = firebase_admin.initialize_app()
    db = firestore_async.client()
    başlat

    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. Eksiksiz bir başvuru için bkz. Admin SDK'yı Başlatın .
    • 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 Admin SDK'yı kendi sunucunuzda (veya başka herhangi 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. Eksiksiz bir başvuru için bkz. Admin SDK'yı Başlatın .
  • Google Cloud
    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()
    
    başlat
  • 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 istemcisi kurma ve oluşturma hakkında daha fazla bilgi için Cloud Firestore Client Libraries bölümüne 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 istemcisi kurma ve oluşturma hakkında daha fazla bilgi için Cloud Firestore Client Libraries bölümüne 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 Koleksiyonlarda depolanan Belgelerde depolar. Cloud Firestore, belgeye ilk kez veri eklediğinizde dolaylı olarak koleksiyonlar ve belgeler oluşturur. Açıkça koleksiyon veya belge oluşturmanız gerekmez.

    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
    var ref: DocumentReference? = nil
    ref = db.collection("users").addDocument(data: [
        "first": "Ada",
        "last": "Lovelace",
        "born": 1815
    ]) { err in
        if let err = err {
            print("Error adding document: \(err)")
        } else {
            print("Document added with ID: \(ref!.documentID)")
        }
    }
    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());
    Piton
    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 istemcisi kurma ve oluşturma hakkında daha fazla bilgi için Cloud Firestore Client Libraries bölümüne 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.
    ref = db.collection("users").addDocument(data: [
        "first": "Alan",
        "middle": "Mathison",
        "last": "Turing",
        "born": 1912
    ]) { err in
        if let err = err {
            print("Error adding document: \(err)")
        } else {
            print("Document added with ID: \(ref!.documentID)")
        }
    }
    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());
    Piton
    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 istemcisi kurma ve oluşturma hakkında daha fazla bilgi için Cloud Firestore Client Libraries bölümüne 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ızlıca 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.
    db.collection("users").getDocuments() { (querySnapshot, err) in
        if let err = err {
            print("Error getting documents: \(err)")
        } else {
            for document in querySnapshot!.documents {
                print("\(document.documentID) => \(document.data())")
            }
        }
    }
    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"));
    }
    Piton
    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 istemcisi kurma ve oluşturma hakkında daha fazla bilgi için Cloud Firestore Client Libraries bölümüne 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

    verilerinizin güvenliğini sağlayın

    Web, Android veya Apple platformları SDK'sını kullanıyorsanız Cloud Firestore'da 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. Konsolun Kurallar sekmesinde güvenlik kurallarınızı değiştirebilirsiniz.

    Kimlik doğrulama 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 adımlar atın. Uygulama Kontrolü belgelerine bakın.

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

    Eğitim videosunu izleyin

    Cloud Firestore mobil istemci kitaplıklarını kullanmaya başlamayla ilgili ayrıntılı rehberlik için aşağıdaki eğitim videolarından 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 izleyerek Cloud Firestore'u gerçek bir uygulamada kullanmayı öğrenin.
    • Veri modeli — Hiyerarşik veriler ve alt koleksiyonlar dahil olmak üzere verilerin Cloud Firestore'da nasıl yapılandırıldığı hakkında daha fazla bilgi edinin.
    • Veri ekle — Cloud Firestore'da veri oluşturma ve güncelleme hakkında daha fazla bilgi edinin.
    • Veri alın — Verilerin nasıl alınacağı hakkında daha fazla bilgi edinin.
    • Basit ve bileşik sorgular gerçekleştirin — Basit ve bileşik sorguları nasıl çalıştıracağınızı öğrenin.
    • Sorguları sıralama ve sınırlama Sorgularınız tarafından döndürülen verileri nasıl sıralayacağınızı ve sınırlayacağınızı öğrenin.