英文:
Is it safe to store collection name in class of firestore Project class file?
问题
是的,可以安全地将集合名称存储在字段中。
英文:
We are making a Firestore query by using collection name, so I thought to store collection name in a static class, or in the same class something like:
private static final String collUsers = "users";
and then use something like db.collections(collUsers).documents()
So is it safe to store collection names in fields?
答案1
得分: 4
Sure, it is. The collection names are always Strings. You can use them directly in your reference:
db.collections("users").documents()
Or you can save that name in a variable. However, if you do that, that variable becomes a constant, as the name of the collection cannot be changed. So most probably the variable name might look like this:
public static final String USERS_COLLECTION = "users";
So the problem is not that you keep these names in your project file, the problem is how you read, write, and delete the data that exists there. In that case, you should always secure that data using Firestore Security Rules.
英文:
> Is it safe to store the collection name in the class of Firestore Project class file?
Sure, it is. The collection names are always Strings. You can use them directly in your reference:
db.collections("users").documents()
Or you can save that name in a variable. However, if you do that, that variable becomes a constant, as the name of the collection cannot be changed. So most probably the variable name might look like this:
public static final String USERS_COLLECTION = "users";
So the problem is not that you keep these names in your project file, the problem is how you read, write, and delete the data that exists there. In that case, you should always secure that data using Firestore Security Rules.
答案2
得分: 1
是的,在设置了保护数据免受滥用和修改的Firestore规则之前,将查询保持开放是安全的。
如果您想了解更多有关保护数据的信息,请阅读这个链接:阅读此文
英文:
Yes, it's safe to keep your query for firestore open, until you have firestore rules in place which guard your data against any misuse and edits.
If you want to know more about securing your data: Read this
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论