UNPKG

3.26 kBMarkdownView Raw
1# Upgrade Guide
2
3This document describes breaking changes and how to upgrade. For a complete list of changes including minor and patch releases, please refer to the [`CHANGELOG`][changelog].
4
5## v5
6
7Support of keys & values other than strings and Buffers has been dropped. Internally `memdown` now stores keys & values as Buffers which solves a number of compatibility issues ([#186](https://github.com/Level/memdown/issues/186)). If you pass in a key or value that isn't a string or Buffer, it will be irreversibly stringified.
8
9## v4
10
11This is an upgrade to `abstract-leveldown@6` which solves long-standing issues around serialization and type support.
12
13### Range options are now serialized
14
15Previously, range options like `lt` were passed through as-is by `abstract-leveldown`, unlike keys. This makes no difference for `memdown` as it does not serialize anything.
16
17### The rules for range options have been relaxed
18
19Because `null`, `undefined`, zero-length strings and zero-length buffers are significant types in encodings like `bytewise` and `charwise`, they became valid as range options in `abstract-leveldown`. This means `db.iterator({ gt: undefined })` is not the same as `db.iterator({})`.
20
21For `memdown`, when used by itself, the behavior of `null`, `undefined`, zero-length strings and zero-length buffers is undefined.
22
23### Nullish values are rejected
24
25In addition to rejecting `null` and `undefined` as _keys_, `abstract-leveldown` now also rejects these types as _values_, due to preexisting significance in streams and iterators.
26
27### Zero-length array keys are rejected
28
29Though this was already the case, `abstract-leveldown` has replaced the behavior with an explicit `Array.isArray()` check and a new error message.
30
31### Browser support
32
33IE10 has been dropped.
34
35## v3
36
37Dropped support for node 4. No other breaking changes.
38
39## v2
40
41This release drops Node.js 0.12, brings `memdown` up to par with latest [`levelup`][levelup] (v2) and [`abstract-leveldown`][abstract-leveldown] (v4), simplifies serialization and removes global state.
42
43### Targets latest [`levelup`][levelup]
44
45Usage has changed to:
46
47```js
48const levelup = require('levelup')
49const memdown = require('memdown')
50
51const db = levelup(memdown())
52```
53
54From the old:
55
56```js
57const db = levelup('mydb', { db: memdown })
58```
59
60### No stringification of keys and values
61
62This means that in addition to Buffers, you can store any JS type without the need for [`encoding-down`][encoding-down]. This release also makes behavior consistent in Node.js and browsers. Please refer to the [README](./README.md) for a detailed explanation.
63
64### No global state or `location` argument
65
66If you previously did this to make a global store:
67
68```js
69const db = levelup('mydb', { db: memdown })
70```
71
72You must now attach the store to a global yourself (if you desire global state):
73
74```js
75const db = window.mydb = levelup(memdown())
76```
77
78### No `null` batch operations
79
80Instead of skipping `null` operations, `db.batch([null])` will throw an error courtesy of [`abstract-leveldown`][abstract-leveldown].
81
82[changelog]: CHANGELOG.md
83
84[abstract-leveldown]: https://github.com/Level/abstract-leveldown
85
86[levelup]: https://github.com/Level/levelup
87
88[encoding-down]: https://github.com/Level/encoding-down