Skip to content

Use of this referencing global scope #65

@shellscape

Description

@shellscape

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions