Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

535
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda