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

180
Vistas
Multiple orderBy() in Firestore Query Produces Error

I want to query Firestore db and order by two fields. Official docs suggest I can simply combine the orderBy statements via orderBy('field1').orderBy('field2') but when I run similar code, I get the following error in console:

Project.js:62 Uncaught (in promise) TypeError: (0 , firebase_firestore__WEBPACK_IMPORTED_MODULE_0__.orderBy)(...).orderBy is not a function

My code:

const projectRef = doc(db, 'projects', projectId)
const docSnap = await getDoc(projectRef)

if(docSnap.exists()) {
    const imagesInfoRef = collection(db, 'projectGalleryImages')
    const imagesInfoDocsSnapshot = await getDocs(query(imagesInfoRef, where('project', '==', projectRef), orderBy('displayOrder').orderBy('createdOn')))
    imagesInfoDocsSnapshot.docs.map(imageInfo => {
        const imageRef = ref(storage, `project/${projectId}/images/${imageInfo.fileName}`)
        loadImageURL(imageRef)
    })
}

Why am I getting this error?

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

0

You're mixing the older namespaced syntax with the newer modular syntax. In the latter, each orderBy call is a standalone instruction:

query(imagesInfoRef, 
  where('project', '==', projectRef),
  orderBy('displayOrder'), // 👈 comma here, instead of a dot
  orderBy('createdOn')
)
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