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

124
Visualizações
PouchDB find method doesn't return docs

in parallel with replication, I run the find query. But when the page is loaded for the first time, the method returns 0 documents. if you reload the page after about 5 seconds, the method returns all the documents

public createIndex = async (): Promise<unknown> => {
    try {
      return await this.database.createIndex({
        index: {
          fields: ['title']
        }
      });
    } catch (e) {
      ErrorHandler.processError(e);

      return null;
    }
  };

public find = async (
    userId: string,
  ): Promise<any> => {
    try {
      return await this.database.find({
        selector: {
          $or: [
            {author: userId},
            {writers: {$regex: userId}},
            {readers: {$regex: userId}},
          ],
          $and: [
            {title: {$gt: null}}
          ],
          $not: [
            {_delete: true}
          ],
        },
        sort: [{title: "asc"}],
        fields: ["_id", "_rev", "id", "title", "created", "modified", "sharedUI", "author", "writers", "readers", "preview"],
      })
    } catch (e) {
      ErrorHandler.processError(e);

      return null;
    }
  };
React.useEffect(() => {
    const storage = new Database('schemes', {username: 'username', password: 'username'});
    storage.createIndex().then(() => {
      storage.find(userId).then((resFind) => {
        console.log('resFind', resFind)
     })
    })

}, [userId]);
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