Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

536
Visualizações
how to get data in firestore by specific user

The logged in user can also see the activities of other users. but I only want the logged in user's activities to be seen. Do I need to make changes in the query section?

  useEffect(()=>{
    const q = query(collection(db,'etkinlik'));
    const unsub = onSnapshot(q,(snap)=>{
      const array = snap.docs.map(doc=>{
        return{
          id : doc.id,
          title : doc.get('title'),
          start: doc.get('start').toDate(),
          allDay : doc.get('allDay')

        }
      });
      setData([...array]);
    })
    return ()=>{unsub()}
  })  
 const handleDateClick = (args) => {
    if(args.jsEvent.altKey) {
      const title= prompt('Enter Title',args.dateStr);
      const event = {
        title: title ? title : args.dateStr,
        start: args.date,
        allDay: true,
        uid: uid,
        owner: user.uid
      }
      addDoc(collection(db,'etkinlik'),event)
    }
  };
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

How to get data in firestore by specific user?

You're looking for query operators with where, like this:

query(collection(db,'etkinlik'), where('uid', '==', uid));

This will query only for documents that fulfill the where condition. However, this doesn't stop other users from query the data.

I only want the logged in user's activities to be seen

Lock the collection down with Security Rules. For example, to make a collection named etkinlik only readable for clients with a matching uid:

service cloud.firestore {
  match /databases/{database}/documents {
    match /etkinlik {
      allow read: if request.auth.uid == resource.data.uid;
    }
  }
}

Assuming that documents in etkinlik have a field uid (as indicated in your source code example; but you also have owner there, so it depends on you how you use those fields).

See docs, to deploy the Security Rules. It's a good idea to use the Firebase Console and test the rules in the Playground section.

about 4 years ago · Juan Pablo Isaza Relatório

0

To restrict a user from seeing certain data (such as other user's data), you will need to develop database rules. Restricting one user from seeing data can also be done locally, but for security reasons you should develop this from the backend.

Security rule instructions for Cloud Firestore and Realtime Datase depending on what you're using.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda