小编mon*_*njo的帖子

Firestore中的性能更高的选项是什么,是一个对象数组还是一个子集合?

我正在考虑使用Firestore的应用程序的最佳数据模型.我不知道哪个选项更具性能/可扩展性?这个:

[Collection] Estimates -> 
    [Document] Estimate1 = items: [{name: 'Design', price: 200}, {name: 'Development', price: 200}]
Run Code Online (Sandbox Code Playgroud)

或者这一个:

[Collection] Estimates -> 
    [Document] Estimate1 ->
        [Collection] Items ->
            [Document] Item 1 = {name: 'Design', price: 200}
            [Document] Item 2 = {name: 'Development', price: 200}
Run Code Online (Sandbox Code Playgroud)

另一方面,除了性能问题之外,在选择数据模型之前,我还有另一个考虑因素.那就是我需要将'估计'节点的所有内容复制到'发票'节点,我不知道我是否可以在两个数据模型中都这样做.

firebase google-cloud-firestore

5
推荐指数
1
解决办法
873
查看次数

我无权访问来自 Firestore 安全规则的自定义声明

我使用 firebase admin sdk 设置了自定义声明。我已经成功地使用它来控制前端甚至 RTDB 的访问,但我无法将它与 Firestore 数据库一起使用。这是我的安全规则:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth.token.admin == true;  
    } 
  }
}
Run Code Online (Sandbox Code Playgroud)

这是我的应用程序中的代码:

   const users = []
   firebase.firestore().collection('users')
    .get()
    .then(function (querySnapshot) {
      querySnapshot.forEach(function (doc) {
        users.push(doc.data())
      })
    })
    .then(() => {
      commit('setUsersList', users)
      commit('setLoading', false)
    })
    .catch(function (error) {
      console.log('Error getting documents:', error)
      commit('setLoading', false)
    })
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

Error: Missing or insufficient permissions
Run Code Online (Sandbox Code Playgroud)

firebase firebase-security google-cloud-firestore

5
推荐指数
1
解决办法
3773
查看次数