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

125
Visualizações
What do my NodeJs Firebase read/write functions actually return?

I come from a language with no promises :-(

I want to code some NodeJS utility functions like these to interface with FireBase. It is my understanding that all FB functions return a promise (but, feel free to correct me).

exports.writeToFireBase(url, value){
    try{
        promise = await admin.database().ref(url).set(value);   
        return promise;
    }

    catch(exception){
        exports.unhandledException(exception);
    }
}

 exports.readFromFireBase(url){
    try{
        let value = admin.database().ref(url).once("value");

        return value;
    }

    catch(exception){
        exports.unhandledException(exception);
    }
}

What are functions actually returning?

In the write case, I guess it is either a promise, or nothing?

In the read case, will my function return the actual data, or a promise to that data? Await looks to me like it is blocking, but I suspect that I am wrong, and that promise to the data is returned from my read function.

Can someone please clarify, before I base too much code on erroneous assumptions?

about 4 years ago · Juan Pablo Isaza
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