【问题标题】:Google.Cloud.Firestore not writing data to firestore emulatorGoogle.Cloud.Firestore 未将数据写入 Firestore 模拟器
【发布时间】:2020-08-01 09:32:42
【问题描述】:

我正在尝试将本地环境中的数据(在我机器上的 iis 上运行)写入我的 Google Firestore 模拟器。代码运行,不会抛出错误,但数据似乎没有被写入 Firestore 模拟器。

使用 firebase CLI 工具 v8.6.0 Google.Cloud.Firestore v2.1.0

    string project = ConfigurationManager.AppSettings["firestore_projectid"];
    Environment.SetEnvironmentVariable("FIRESTORE_EMULATOR_HOST", "localhost:8080");
    FirestoreDb db = new FirestoreDbBuilder
        {
            ProjectId = project,
            EmulatorDetection = Google.Api.Gax.EmulatorDetection.EmulatorOnly
              
        }.Build();

    var dto = await GetLiveStreamDto();

    DocumentReference docRef = db
        .Collection("Events")
        .Document("123456789")
         

    await docRef.SetAsync(dto, SetOptions.MergeAll);

【问题讨论】:

    标签: c# .net firebase google-cloud-firestore emulation


    【解决方案1】:

    对于那些想知道我能够通过问题中提供的代码连接到模拟器的人。 Firestore C# 文档中并不清楚。

        string project = ConfigurationManager.AppSettings["firestore_projectid"];
        Environment.SetEnvironmentVariable("FIRESTORE_EMULATOR_HOST", "localhost:8080");
        FirestoreDb db = new FirestoreDbBuilder
            {
                ProjectId = project,
                EmulatorDetection = Google.Api.Gax.EmulatorDetection.EmulatorOnly
                  
            }.Build();
    

    【讨论】:

      【解决方案2】:

      firebase 模拟器似乎不支持 c#。在这里检查:

      https://firebase.google.com/docs/emulator-suite#feature-matrix

      对于 admin sdk 只是 Nodejs

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-01-07
        • 2022-01-16
        • 2019-06-06
        • 1970-01-01
        • 2019-10-29
        • 1970-01-01
        • 2020-01-10
        • 2021-07-03
        相关资源
        最近更新 更多