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

233
Views
FirebaseError: Llamada a la función updateDoc() con datos no válidos. serverTimestamp() no se admite actualmente dentro de matrices

Estoy tratando de actualizar el documento con la nueva matriz de comments , pero recibo este error cuando envío un nuevo comentario. En cada documento, hay una matriz (matriz de comentarios) de objeto (comentario único)

 FirebaseError: Function updateDoc() called with invalid data. serverTimestamp() is not currently supported inside arrays (found in document solutions/wLflWVhLueEKjBBknHNi)

Comente el código de envío:

 const handleSubmit = async (e) => { e.preventDefault() try { const commentToAdd = { id: Math.floor(Math.random() * 10000), content: newComment.trim(), reactions: [], user: { userID: user.uid, avatarURL: user.photoURL, displayName: user.displayName, username: user.reloadUserInfo.screenName, }, replies: [], createdAt: serverTimestamp(), } await updateDocument(id, { comments: [...solution.comments, commentToAdd], }) setNewComment("") if (response) { console.log(response.error) } } catch (error) { console.log(error) } }

Actualizar código de enlace del documento:

 const updateDocument = async (id, updates) => { console.log(JSON.stringify(updates)) dispatch({ type: "IS_PENDING" }) try { const updatedDocument = await updateDoc(doc(db, c, id), updates) dispatchIfNotCancelled({ type: "UPDATED_DOCUMENT", payload: updatedDocument }) return updatedDocument } catch (error) { dispatchIfNotCancelled({ type: "ERROR", payload: error }) return null } }

Alguien por favor me ayude con esto.

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

0

En vez de:

 createdAt: serverTimestamp()

Utilizar este:

 createdAt: Timestamp.now()

Puedes encontrar más información 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!