保护Firestore中的特定“文档"字段 [英] Securing specific Document fields in Firestore
问题描述
我正在尝试创建一个简单的系统,该系统允许用户使用他们提供的信息来创建一个帐户.现在,我将所有数据存储在一个集合users
中,该集合具有一些表示用户的文档.
我想将用户的一些敏感数据(例如电子邮件地址和电话号码)保密.在Firebase数据库中,我将创建以下内容:
I'm trying to create a simple system that allows users to create an account with info that they provided. Right now, I store all the data in a Collection users
which has some Documents that represents users.
I'd like to keep some sensitive data of the user, such as the email address and phone number, private. In Firebase Database I would've created something like this:
users: {
uid: {
public_info:...
private_info:...
}
}
在这里保护数据非常简单.我只是为private_info
和public_info
写不同的规则集.
这样在Firestore中如何实现?
Protecting the data in here is pretty straight forward. I would simply write different rule sets for the private_info
and public_info
.
How would something like this be achieved in Firestore?
推荐答案
为用户的公共和私有数据使用不同的顶级集合,并适当地设置其规则.
Use different top-level collections for user public and private data, and set their rules appropriately.
这篇关于保护Firestore中的特定“文档"字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!