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

122
Views
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
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!