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

Drop support of key & value types other than string and Buffer #179

Merged
merged 1 commit into from
Sep 15, 2019

Conversation

vweevers
Copy link
Member

@vweevers vweevers commented Sep 8, 2019

Closes #174. WIP.

@vweevers vweevers added the semver-major Changes that break backward compatibility label Sep 8, 2019
@vweevers vweevers added this to In progress in Level (old board) via automation Sep 8, 2019
index.js Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
if (err) throw err
})
})
```
Copy link
Member Author

@vweevers vweevers Sep 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include this? I wrote it to see if it could work, and it does for common cases, but not if:

  • You target old browsers that don't support binary keys (IE, Edge and a few others, the ones in red here)
  • You used custom key or value types (numbers etc); these come out stringified
  • You mixed key types (e.g. strings and buffers); keys may conflict.

We could (also) choose to:

  • Drop browsers that don't support binary keys
  • Store keys as base64 strings for these browsers (you won't be able to read existing string data though).
  • Use a new database prefix (to avoid reading old data altogether)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, lets include this.

@vweevers vweevers marked this pull request as ready for review September 14, 2019 06:52
if (err) throw err
})
})
```
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also considered adding the upgrade method to the manifest, which level (and layers in between) could detect and then proxy, but it's too early for that. We should first add manifests to abstract-leveldown and work out the details there.

@vweevers vweevers merged commit f207ae6 into master Sep 15, 2019
Level (old board) automation moved this from Review to Done Sep 15, 2019
@vweevers vweevers deleted the drop-custom-types branch September 15, 2019 18:52
achingbrain added a commit to ipfs/js-ipfs-repo-migrations that referenced this pull request Jan 28, 2021
We use the [level](https://www.npmjs.com/package/level) module to supply
either [leveldown](http://npmjs.com/package/leveldown) or [level-js](https://www.npmjs.com/package/level-js)
to [datastore-level](https://www.npmjs.com/package/datastore-level) depending
on if we're running under node or in the browser.

`level@6.x.x` upgrades the `level-js` dependency from `4.x.x` to `5.x.x`
which includes the changes from [Level/level-js#179](Level/level-js#179)
so `>5.x.x` requires all database keys/values to be Uint8Arrays and they
can no longer be strings.

We already store values as Uint8Arrays but our keys are strings, so here
we add a migration to converts all datastore keys to Uint8Arrays.

N.b. `leveldown` already does this conversion for us so this migration
only needs to run in the browser.
achingbrain added a commit to ipfs/js-ipfs-repo-migrations that referenced this pull request Jan 28, 2021
We use the [level](https://www.npmjs.com/package/level) module to supply
either [leveldown](http://npmjs.com/package/leveldown) or
[level-js](https://www.npmjs.com/package/level-js)
to [datastore-level](https://www.npmjs.com/package/datastore-level) depending
on if we're running under node or in the browser.

`level@6.x.x` upgrades the `level-js` dependency from `4.x.x` to `5.x.x`
which includes the changes from
[Level/level-js#179](Level/level-js#179)
so `>5.x.x` requires all database keys/values to be Uint8Arrays and they
can no longer be strings.

We already store values as Uint8Arrays but our keys are strings, so here
we add a migration to converts all datastore keys to Uint8Arrays.

N.b. `leveldown` already does this conversion for us so this migration
only needs to run in the browser.
achingbrain added a commit to ipfs/js-ipfs-repo-migrations that referenced this pull request Jan 28, 2021
We use the [level](https://www.npmjs.com/package/level) module to supply
either [leveldown](http://npmjs.com/package/leveldown) or
[level-js](https://www.npmjs.com/package/level-js)
to [datastore-level](https://www.npmjs.com/package/datastore-level) depending
on if we're running under node or in the browser.

`level@6.x.x` upgrades the `level-js` dependency from `4.x.x` to `5.x.x`
which includes the changes from
[Level/level-js#179](Level/level-js#179)
so `>5.x.x` requires all database keys/values to be Uint8Arrays and they
can no longer be strings.

We already store values as Uint8Arrays but our keys are strings, so here
we add a migration to converts all datastore keys to Uint8Arrays.

N.b. `leveldown` already does this conversion for us so this migration
only needs to run in the browser.
achingbrain added a commit to ipfs/js-ipfs-repo-migrations that referenced this pull request Jan 28, 2021
We use the [level](https://www.npmjs.com/package/level) module to supply
either [leveldown](http://npmjs.com/package/leveldown) or
[level-js](https://www.npmjs.com/package/level-js)
to [datastore-level](https://www.npmjs.com/package/datastore-level) depending
on if we're running under node or in the browser.

`level@6.x.x` upgrades the `level-js` dependency from `4.x.x` to `5.x.x`
which includes the changes from
[Level/level-js#179](Level/level-js#179)
so `>5.x.x` requires all database keys/values to be Uint8Arrays and they
can no longer be strings.

We already store values as Uint8Arrays but our keys are strings, so here
we add a migration to converts all datastore keys to Uint8Arrays.

N.b. `leveldown` already does this conversion for us so this migration
only needs to run in the browser.
achingbrain added a commit to ipfs/js-ipfs-repo-migrations that referenced this pull request Jan 29, 2021
We use the [level](https://www.npmjs.com/package/level) module to supply either [leveldown](http://npmjs.com/package/leveldown) or [level-js](https://www.npmjs.com/package/level-js) to [datastore-level](https://www.npmjs.com/package/datastore-level) depending on if we're running under node or in the browser.

`level@6.x.x` upgrades the `level-js` dependency from `4.x.x` to `5.x.x` which includes the changes from [Level/level-js#179](Level/level-js#179) so `>5.x.x` requires all database keys/values to be Uint8Arrays and they can no longer be strings.

We already store values as Uint8Arrays but our keys are strings, so here we add a migration to converts all datastore keys to Uint8Arrays.

N.b. `leveldown` already does this conversion for us so this migration only needs to run in the browser.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-major Changes that break backward compatibility
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Drop support of key & value types other than string and Buffer
2 participants