Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何在firestore中编写文档_Reactjs_Firebase_Google Cloud Firestore - Fatal编程技术网

Reactjs 如何在firestore中编写文档

Reactjs 如何在firestore中编写文档,reactjs,firebase,google-cloud-firestore,Reactjs,Firebase,Google Cloud Firestore,我正在尝试写一个新文档,如下所示: database.collection('NegociosDev').doc('Peluquerías').collection('Negocios').doc('PR01').collection('citas').add({ CheckIn: formattedDate(citaDate) + ' ' + formattedTime(horaSelec), CheckOut: fechaFinal.toStr

我正在尝试写一个新文档,如下所示:

database.collection('NegociosDev').doc('Peluquerías').collection('Negocios').doc('PR01').collection('citas').add({
            CheckIn: formattedDate(citaDate) + ' ' + formattedTime(horaSelec),
            CheckOut: fechaFinal.toString(),
            Dirección: 'Avenida Los Majuelos 54',
            Negocio: 'PRIVILEGE SALONES',
            Precio: pre.toString(),
            Servicio: servicioSeleccionado.toString(),
            extraInformation: empleadoSelect.toString(),
            idUsuario: idUser.toString(),
        })
但每次我尝试写任何东西时(我可以阅读),我都会遇到这个错误:

未处理的承诺拒绝:FirebaseError:缺少权限或权限不足

使用此规则:

rules_version = '2';
 service cloud.firestore {
  match /databases/{database}/documents {
   match /{document=**} {
    allow write: if request.auth.uid != null;
    allow read;
  }
 }
}

我没有做任何身份验证,我只是想写一些东西,但我不想更改规则。

您必须正确设置firestore规则

我建议你看这段官方视频[1],他们会解释你需要知道的一切

该视频是“了解云Firestore”播放列表的一部分[2]。我真的建议你看整个播放列表。不会花太长时间,而且真的会有回报

[1]
[2]

我没有做任何身份验证,我只是想写一些东西,但我不想改变规则

如果不进行身份验证(基于该规则),您将无法写入/

如果您决定删除rile
允许写入:如果为true
,请注意这是不安全的,您可以在完成测试后将其设置回原位

否则,您可以对您的用户进行身份验证


可能会检查本地模拟器,可能会对您有所帮助,

会检查文档,但没有办法(不更改规则)编写,即使我是管理员?不,没有“管理员”(指项目所有者)的概念,您也可以尝试本地模拟器,我将更新我的答案,为您提供文档,但我还没有检查自己,可能您需要更改规则,但在您的本地环境中,这是可以的,否则,没有,没有办法绕过安全规则,因为通过设计,它的创建正是为了避免这种情况。