Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of this referencing global scope #65

Open
shellscape opened this issue May 4, 2020 · 0 comments
Open

Use of this referencing global scope #65

shellscape opened this issue May 4, 2020 · 0 comments

Comments

@shellscape
Copy link

Use of and assumption of this being the database reference is resulting in inconsistent behavior. Specifically this line

var db = this;

If declaring a database namespace as such:

  const db = {
    config: new PouchDB('config', { adapter })
  }

And running the upset method as such:

    await db.users.upsert(`${data.userName}-cursor`, (doc) => {
      (doc as CursorDoc).cursor = data.nextCursor;
      return doc;
    });

Will result in the db variable being assigned to the global scope and .get being undefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant