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

256
Vistas
Query nested objects firebase

I am trying to get the orders from my db where the email property (which is inside the buyer object) is equal to the user's email; but I keep getting an empty array without orders.

const ProfileContainer = () => {
let { user } = useContext(AppContext)

const [orders, setOrders] = useState([])
const [loading, setLoading] = useState(true)

useEffect(() => {
    console.log(orders)
}, [orders])

useEffect(() => {
    const db = getFirestore()
    const ordersRef = query(collection(db, 'orders'), where(('buyer', 'email'), '==', user.email))
    getDocs(ordersRef)
        .then(res => {
            setOrders(res.docs.map((order) => ({ ...order.data() })))
        })
        .finally(() => setLoading(false))
}, [user])

return (
    <>
        {loading ?
            <Spinner />
            :
            <Profile
                orders={orders}
                user={user}

            />
        }
    </>
)
}

This is my db firebase schema

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use dot notation to build the path to the nest field.

const ordersRef = query(
    collection(db, 'orders'),
    where('buyer.email', '==', user.email)
)

See also

  • How to Query a nested field in Firestore?
  • Update fields in nested objects in firestore documents?
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