小编Prz*_*emo的帖子

如何在 AngularFire 7 新 api 中使用“where”?

我将 AngularFire 升级到 7,并且在使用 .where 和 collectionReference 时遇到问题。那么简单..如何正确使用它?

我尝试使用“@angular/fire/firestore”中的“集合”,例如:

const ref = collection(this.firestore, 'collectionName');
Run Code Online (Sandbox Code Playgroud)

但裁判没有说“哪里”之类的。

我知道“@angular/fire/firestore”也有“query”和“where”,但我不知道如何使用它。

如何使用新 API 的“where”在集合中查找文档?

javascript firebase google-cloud-platform angularfire2 google-cloud-firestore

10
推荐指数
3
解决办法
2956
查看次数

如何将 firebase webapp 与 chrome 扩展进行通信以避免双重登录

我在外部网页和 Chrome 扩展程序之间创建通信时遇到问题。我想我需要这样的东西。

  1. 用户尝试使用 Firebase Auth(使用 google/Fb/email - 密码提供商)通过“example.com”上的登录表单登录
  2. 如果用户登录成功,则相同的凭据将发送到 chrome 扩展程序
  3. 扩展程序使用获取的凭据调用signInWithCredential,并尝试再次登录
  4. 如果一切正常,则用户可以使用 context_script 使用 firebase dB

但这是正确的方法吗?这是一种将凭据(例如电子邮件/密码、令牌)从网页发送到扩展程序的安全解决方案(即使我使用带有扩展程序 ID 的 runtime.sendMessage 仅将数据发送到特定扩展程序)?

目前,Web 应用程序和扩展程序身份验证是分开工作的。如果用户通过网络应用程序登录,扩展程序不会知道这一点,反之亦然。我需要像 Grammarly 或 moz.com 这样的通信,用户通过网页登录,之后他不需要通过扩展程序登录来使用他的帐户。

google-chrome-extension firebase-authentication google-cloud-firestore

6
推荐指数
1
解决办法
651
查看次数

用.map转换Observable

我在转换可观察对象时遇到问题。详情如下:

我有这样的数据

[
    {
      'firstName': 'John',
      'lastName': 'Cash',
      'age': 20
    }
  ];
Run Code Online (Sandbox Code Playgroud)

然后我从api中获得以下数据:

  public getData(): Observable<Data[]> {
    return this.http.get('xxx')
    .map(
      response => response.json()
    );
  }
Run Code Online (Sandbox Code Playgroud)

然后,我正在尝试订阅:

this.service.getData.subscribe(
        (res) => this.data = res
      );
Run Code Online (Sandbox Code Playgroud)

没关系,它正在工作。但是我需要修改对象的结构,并且我想使用.map将接收到的对象转换为以下模式:

[
    {
      'firstName': 'John',
      'lastName': 'Cash',
      'age': 20,
'newProperty': 'value'
    }
  ];
Run Code Online (Sandbox Code Playgroud)

..对我没有任何帮助..:/即使我不想添加新属性,但修改例如firstName的值:

  .map(
    return x => x[0].firstName = 'asd'
  )
Run Code Online (Sandbox Code Playgroud)

它不起作用(类型'string'不能分配给类型'Data []',我知道它的意思,但是我不知道该怎么做,我的错误在哪里?)

observable rxjs

2
推荐指数
2
解决办法
1万
查看次数

如何在functions.auth.user().onCreate完成后才完成登录

我正在使用 firebase 函数,并且有一个函数可以在用户创建时添加新集合。问题是有时用户在功能完成之前已登录,因此用户已登录但尚未创建新集合(然后我收到错误消息“权限丢失或不足。因为规则找不到该集合”)。我该如何处理?

是否可以仅在所有内容都来自

export const createCollection = functions.auth.user().onCreate(async user => {
  try {
    const addLanguages = await addFirst();
    const addSecondCollection = await addSecond();

    async function addFirst() {
      const userRef = admin.firestore().doc(`languages/${user.uid}`);
      await userRef.set(
        {
          language: null
        },
        { merge: true }
      );

      return 'done';
    }

    async function addSecond() {
      // ...
    }

    return await Promise.all([addLanguages, addSecondCollection]);
  } catch (error) {
    throw new functions.https.HttpsError('unknown', error);
  }
});
Run Code Online (Sandbox Code Playgroud)

完成了吗?所以谷歌提供者窗口关闭并且用户仅在此之后登录?(并且不要使用 setTimeouts 等)

firebase firebase-authentication google-cloud-functions google-cloud-firestore

0
推荐指数
1
解决办法
527
查看次数