在Firestore项目类文件的类中存储集合名称是否安全?

huangapple go评论163阅读模式
英文:

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

huangapple
  • 本文由 发表于 2020年8月2日 17:07:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/63214246.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定