Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

103
Visualizações
how to use variable in firestore query

I use firebase firestore db. This project have two main collection "securecollection" and "publiccollection". The securecollection is where all important data is stored and only accessible to authenticated users. But in order for some information to be visible to guest users, I am copying them into the publiccollection. Then, I want to save the id of this newly created public document in the secure document.

When I write a variable db.collection('securecollection').doc(secureDocid).update({ inside the query sentence, I get this error:

Uncaught (in promise) TypeError: o.indexOf is not a function

If I write the id as text db.collection('securecollection').doc('7llDqIWlmE5VM69Zzle2').update({, the code works.

Here is my code:

function toggleOlustur(secureDocid) {
  const db = firebase.firestore();
  db.collection("securecollection").get()
    .then(querySnapshot => {
      querySnapshot.forEach(doc => {
        if (doc.id == secureDocid) {
          db.collection("publiccollection").add({
              oad: doc.data().oad,
              osad: doc.data().osad,
              opuan: doc.data().opuan,
              odtarih: doc.data().odtarih,
              odurum: "1",
            })
            .then((docRef) => {
              db.collection('securecollection').doc(secureDocid).update({
                preference: docRef.id
              })
            });
        }
      });
    });
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The doc() method expects a string argument, and from the error message it sounds like your secureDocid is not a string value. If you console.log(JSON.stringify(secureDocid)) you can see what it outputs, which might help to figure out the problem.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda