我正在使用React.js从Firebase查询文档中的字段。然而,当我尝试获取数据时,我总是得到一个错误。代码、Firestore上的集合和错误消息如下。如何在不遇到此错误的情况下正确查询数据的特定字段?
import React from 'react';
import styled from 'styled-components';
import { firestore } from '../../firebase/firebase.utils';
class Economics extends React.Component {
c
我从firebase数据库获取所有数据,并将其显示在列表中。现在我想要做的是,当我点击一个特定的元素时,这个特定元素的所有数据都只能获取。我使用的是Next.js/react.js,这是一个管理防火墙连接的基本文件。
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app"
import { getFirestore } from "@firebase/firestore"
// TODO: Add SDKs for
我有一个基于Authentication和的颤振应用程序,我通过 firebase添加了用户(蓝色按钮),并在代码中保留了ID,以便这个用户是administrator,的常规用户可以通过应用程序创建一个帐户(电子邮件和密码),我想要的是确保administrator是唯一可以从数据库中删除数据的人,而其他用户只允许读写,所以我这样做了:
我将CloudFi还原项目中的角色更改为:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match
所以问题是,当我试图使用forEach函数获取详细信息时,它会给出所有用户的详细信息,这些详细信息可以在firestore..let me explain上使用代码进行解释: 下面是我在配置文件页面中获取详细信息的代码: import React from 'react';
import firebase from 'firebase';
const firestore = firebase.firestore();
class ProfilePage extends React.Component {
state = {
prof
我目前有安全规则,允许用户只从名为"153“的集合中读取。
在Android中,我访问Firestore并调用Firestore实例上的.collection("153").get()...从该集合中检索数据。
相反,如果Android代码读取.collection("999").get...,则该权限将被拒绝,这是应该的。
安全规则:
service cloud.firestore {
match /databases/{database}/documents {
// FULL ADMIN ACCESS
match /{docum
我一直在谷歌搜索如何在firestore中将对象添加到数组中,发现arrayUnion()可以将对象添加到firestore数组中,但它只将对象添加到数组的最后一个索引中,但如何将其添加到数组的第一个索引中? //add "greater_virginia" into last index of array
washingtonRef.update({
regions: firebase.firestore.FieldValue.arrayUnion("greater_virginia")
});
//how to add "greater_
我的Firestore数据库是这样的: - Song [Collection]
- Some
- Data
- User [Collection]
- Some
- Data
- likedSong [Collection]
- Same
- Data as
- Songs 因此,用户可以喜欢一些歌曲,并将它们存储在用户文档中。 但当一首歌被删除时,我希望用户下的记录也被删除。 我如何才能做到这一点? 我的第一个想法是: firestore.collectionGroup("likedSongs
如何锁定对顶级集合的访问?我想阻止人们列出或删除顶级集合。 此规则集是否会阻止列出和删除顶级集合,但允许完全访问文档? rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
allow get;
allow list: if false;
allow create;
allow update;
allow delete: if false;
match /{document=**} {
all