Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

126
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda