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

Doc suggestion: point out that getAttachment returns a reference #52

Open
DarrenCook opened this issue Aug 30, 2021 · 0 comments
Open

Comments

@DarrenCook
Copy link

If you modify the Uint8Array that getAttachment() returns, the data inside the (in-memory) DB gets changed too.

This was unexpected, and I believe it is different to the way normal PouchDB behaves.

I've shown some code below to demonstrate the problem. I think a simple fix is to run it through a Uint8Array constructor.

const blob = new Uint8Array( await db.getAttachment(id, fname) )

I was originally going to say this just needs to be written in the docs... but as I've been writing this up, if the point of the pouchdb-memory adapter is to simulate the real thing, then maybe the above code snippet belongs in getAttachment() ?

const blob = await db.getAttachment(id, fname)
const blob2 = await db.getAttachment(id, fname)
blob === blob2  // true
blob[0] = 77
const blob3 = await db.getAttachment(id, fname)
blob[3] === 77
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