Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

328
Views
Funciones de Firebase: la función orderBy no funciona

El siguiente código funciona en el emulador, pero devuelve una matriz vacía en firebase cuando includeVideos o includeAudios es false :

 let query = db.collection("content"); if (includeVideos && !includeAudios) { query = query.where("type", '==', "video").orderBy("type"); } if (includeAudios && !includeVideos) { query = query.where("type", '==', "audio").orderBy("type"); } if (!includeVideos && !includeAudios) { return {empty json....} } if (matchingPersonID != undefined) { query = query.where("attributionID", '==', matchingPersonID).orderBy("attributionID"); } //either categories OR matchingSeriesID is always undefined/empty if (matchingSeriesID != undefined) { query = query.where("seriesIDs", 'array-contains', matchingSeriesID).orderBy("seriesIDs"); } if (matchingCategories.length != 0) { // 'OR' LOGIC query = query.where("categories", 'array-contains-any', matchingCategories).orderBy("categories"); } if (lastDocumentID != undefined) { await db.collection("content").doc(lastDocumentID).get().then((snapshot) => { query = query.startAfter(snapshot); log(`starting after document ${snapshot}`) }) } //the code works when this line is removed, but the query needs to be sorted by time in order for pagination to work query = query.orderBy("upload_date", "desc"); return query.limit(getNext).get()...

No recibo mensajes de error en los registros de la nube de Google, por lo que no tengo una manera fácil de crear un índice, si eso es lo que necesito hacer. En firestore, los campos upload_date , attributionID , type , seriesIDs y categories están todos en el mismo nivel en el documento.

¡Cualquier ayuda sería muy apreciada!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Como comentas, parece que falta un índice para ese campo.

Esta documentación menciona dos formas de manejar estos índices:

  • Mediante el uso de la CLI. Puede llevar sus índices a un archivo local en formato JSON. Para esto, ejecute firebase firestore:indexes dentro de su carpeta de proyecto de firebase, obtendrá una salida JSON formateada para que la copie, agregue una nueva y luego impleméntela con firebase deploy --only firestore:indexes .

  • Efectivamente, puedes usar la URL generada por Firebase cuando detecta el error de usar un índice que no existe, pero también puedes hacerlo a mano desde la consola Firebase de la aplicación:

ingrese la descripción de la imagen aquí

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!