There has been quite some work done for this new major version:
- Make
levelup
more generic by reducing focus onleveldown
andLevelDB
. - Make
levelup
more generic by removing code related to encodings, which would allow *down implementations to manage encodings themselves. - Use
standard
as linter to avoid bikeshedding. - Add a native
Promise
API for promise using geeks. Many have been asking for this. Alsoasync/await
is awesome.
Point 1
and 2
also helps out with reducing complexity.
Since levelup
no longer tries to load leveldown
as a default backend you have to provide a backend instance yourself.
So if you previously did:
$ npm i levelup leveldown --save
And in your code you did something like:
const levelup = require('levelup')
const db = levelup('/path/to/db')
You should now do (for identical functionality):
const levelup = require('levelup')
const encode = require('encoding-down')
const leveldown = require('leveldown')
const db = levelup(encode(leveldown('/path/to/db')))
Note that we have moved out encodings into encoding-down
, which in itself is a *down that wraps a *down (meta ftw). It basically just sits in between levelup
and the actual backend to operate on encodings for keys and values. Default encoding is 'utf8'
like before.
This obviously means everyone has to do a lot of code rewrite which is bad. So we aim to fix this by putting that code into level@2.0.0
, which already is used as a convenience package.
Switching from levelup
and leveldown
combo to only using level
you would do:
const level = require('level')
const db = level('/path/to/db')
Also, we aim to simplify using memdown
in the same way by updating level-mem
.
For more advanced usage with custom versions of abstract-leveldown
, the first parameter to levelup()
should be an abstract-leveldown
instead of passing a factory function via options.db
.
So if you previously did:
const db = levelup('/path/to/db', {
db: function (location) {
return new CustomLevelDOWN(location)
}
})
You should now do (for identical functionality):
const encode = require('encoding-down')
const db = levelup(encode(new CustomLevelDOWN('/path/to/db')))
- [
1dda39eb17
] - rename test for maybeError() for clarity (Lars-Magnus Skog) - [
77f027de38
] - ignore temporary dbs in test folder (Lars-Magnus Skog) - [
e98fc7f14b
] - fix failing tests (Lars-Magnus Skog) - [
1f8d697eef
] - ✅ add failing tests for maybeError() and closed db (Lars-Magnus Skog) - [
37b36ee45b
] - 🚚 move lib/util.js to lib/promisify.js (Lars-Magnus Skog) - [
bb3df7b587
] - 💥 remove dispatchError(), callback is always a function (Lars-Magnus Skog) - [
1fac4fb11c
] - ✨ callback is always a function (Lars-Magnus Skog) - [
8a58d6a081
] - 📝 update docs (Lars-Magnus Skog) - [
f2bf3d2cfa
] - 💥 remove encodings (Lars-Magnus Skog) - [
5379fc69fe
] - 💥 remove isDefined, not used (Lars-Magnus Skog) - [
8b1693e1bb
] - add promise error handling test (Julian Gruber) - [
41bd624c74
] - docs: add Promise#catch (Julian Gruber) - [
651bb588c9
] - clarify wording (Julian Gruber) - [
08757ae2a2
] - docs: we use native promises (Julian Gruber) - [
3993dbef00
] - add promise docs (Julian Gruber) - [
5ddbef9bca
] - add promise tests (Julian Gruber) - [
2d72c7bc6b
] - travis: drop node 0.12 & 4 (Julian Gruber) - [
c74e608127
] - simplify util.promisify. thanks @vweever! (Julian Gruber) - [
fed3a2d397
] - fix early returns (Julian Gruber) - [
7488a6695a
] - style (Julian Gruber) - [
7790d928bb
] - promisify: tests pass (Julian Gruber) - [
96353b0dd7
] - add greenkeeper badge (Lars-Magnus Skog) - [
6a9c97833d
] - ✨ 2016 -> 2017 (Lars-Magnus Skog) - [
f749ed706f
] - remove browser field from package.json (Lars-Magnus Skog) - [
45ec2e18de
] - ✨ options parameter in maybeError() not used (Lars-Magnus Skog) - [
c7b95a0b4c
] - ✨ use AbstractLevelDOWN#status ✅ add test to validate old backends (Lars-Magnus Skog) - [
34fe873e2c
] - db as first parameter 🔥 remove location ⬆️ update deferred-leveldown 📝 (Lars-Magnus Skog) - [
cf9033cc86
] - remove optional leveldown (pass in as options.db) (Lars-Magnus Skog) - [
feaeaea82b
] - 🔥 remove .fillCache (Lars-Magnus Skog) - [
aa4f905f99
] - 🔥 remove .sync (Lars-Magnus Skog) - [
e897ceae33
] - 🔥 remove .cacheSize (Lars-Magnus Skog) - [
9c7ea3189e
] - 🔥 remove .compression (Lars-Magnus Skog) - [
26e2e05b86
] - 🔥 remove .createIfMissing (Lars-Magnus Skog) - [
7c16fe9799
] - 🔥 remove .errorIfExists (Lars-Magnus Skog) - [
0b3792acdf
] - 🔥 remove approximateSize(), destroy(), repair() and getProperty() (Lars-Magnus Skog)
- [
6ae45d83b6
] - dispatchError() and readError() are voids (Lars-Magnus Skog) - [
c8e22e70bd
] - util.deprecate static functions (Julian Gruber) - [
ef0ba86c99
] - target multiple iojs versions, remove notifications (Lars-Magnus Skog) - [
e19ec96ed7
] - deprecate .approximateSize() (Julian Gruber) - [
9c32ca9fcd
] - refactor read streams using level-iterator-stream and level-codec (Julian Gruber) - [
8015e088cb
] - tap -> tape + faucet (Lars-Magnus Skog) - [
af125b580c
] - fix readStream *AsBuffer options (Julian Gruber) - [
61b44463da
] - update dependencies (Lars-Magnus Skog) - [
90352e999c
] - update changelog from 0.18.6 to 0.19.0 (Lars-Magnus Skog) - [
b17e9e775b
] - Fixed valueEncoding bug by passing options without array. (Braydon Fuller) - [
9576842794
] - Added test for valueEncoding "hex" for createReadStream (Braydon Fuller) - [
b9ce2ba2c5
] - s/rvagg/node-/level// (Lars-Magnus Skog) - [
7460209eb6
] - fix stream-bench.js (Julian Gruber) - [
2a2780c65c
] - refactor ltgt encoding (Julian Gruber) - [
f53e349ec7
] - refactor iterators using new deferred-leveldown (Julian Gruber) - [
e811f7e598
] - remove leveled tests (Julian Gruber) - [
b37cf16445
] - fix benchmarks by installing leveldown@^0.10.4 (Julian Gruber) - [
187711c96c
] - use level-codec (Julian Gruber) - [
a1fda6bf2f
] - extract error codes into level-errors module (Lars-Magnus Skog) - [
f4e5a44530
] - remove reference to write-stream and iterators (Lars-Magnus Skog) - [
7372fceb4a
] - Changed options for get to same as put (Richard Littauer) - [
7686899b6c
] - add node 0.12 and iojs on travis (Lars-Magnus Skog) - [
4aa6e8b7a5
] - remove encoding option (Julian Gruber) - [
b0247a436e
] - Added errors to the available namespace when requiring 'levelup'. (Braydon Fuller) - [
8b8da57f7a
] - clean up old level-ws reference (Lars-Magnus Skog) - [
3d26d39a43
] - update README with info on why WriteStream was removed (Lars-Magnus Skog) - [
ba51315047
] - add Jarrett Cruger as contributor (Lars-Magnus Skog) - [
ed89907f33
] - remove unused dependencies (Lars-Magnus Skog) - [
6067bb4467
] - [doc] beginning of readme adjustment (Jarrett Cruger) - [
78a06b3c10
] - [fix] update travis and package.json scripts (Jarrett Cruger) - [
fcdd49b039
] - [rm test] remove fstream based tests (Jarrett Cruger) - [
fb73bdecc0
] - [fix] removecopy
as it requires write-stream (Jarrett Cruger) - [
616da299f9
] - [fix test] remove references to write-stream in tests (Jarrett Cruger) - [
a712e623a7
] - [fix] remove references to write-stream (Jarrett Cruger) - [
9e6a6b7ef4
] - update logo and copyright (Lars-Magnus Skog) - [
8b339def43
] - check notFound on err (Brian Woodward) - [
36658a2c7d
] - support values to be null/undefined (David Björklund) - [
f0bc944005
] - explicit devdep versions (Rod Vagg) - [
c951f094eb
] - Use newer memdown store. Fixes build. (Eduardo Sorribas) - [
c2c12c9380
] - better document #del method (Ben West) - [
2410aa3aff
] - resolve #261, explain args to callback to #del (Ben West) - [
ef28adbe71
] - explicit devdep versions (Rod Vagg) - [
723391bb93
] - Use newer memdown store. Fixes build. (Eduardo Sorribas) - [
23b3f7be19
] - better document #del method (Ben West) - [
02bb5c3856
] - resolve #261, explain args to callback to #del (Ben West) - [
e77bbd4c7d
] - support values to be null/undefined (David Björklund) - [
b9117a001b
] - fixes the leveldb link (Manuel Ernst) - [
3d541dbfc9
] - remove 0.8 from travis (Rod Vagg)
- [
7f14058440
] - minor whitespace changes (Rod Vagg) - [
9e6d335df2
] - fix license (Rod Vagg) - [
74caa18c09
] - minor style fixes (Rod Vagg) - [
1c7bc43d01
] - update nodeico badge (Rod Vagg) - [
b6357cc323
] - Use highest/lowest instead of largest/smallest (Arnout Engelen) - [
e45ce4e9d5
] - Document what 'limit' does in 'reverse' mode (Arnout Engelen) - [
9004e9db69
] - Discourage the use of start/end a bit (Arnout Engelen) - [
6178d69cdc
] - merge (Dominic Tarr) - [
e3ab0ebe03
] - document with comments (Dominic Tarr) - [
bb88572c15
] - unmention bops (Dominic Tarr) - [
45df8e668e
] - clarify ltgt (Dominic Tarr) - [
54eba03305
] - binary encoding in the browser (Calvin Metcalf)
- (lots of stuff since 0.18.1 not recorded in changelog, ooops)
- Extracted encoding / codec to separate modules (@dominictarr)
- Make chained-batch obey global LevelUP object options (@mcavage)
- Upgrade to LevelDOWN@0.10.0 (and bops@0.1.0 and readable-stream@1.1.9) (@rvagg)
- Undo factory pattern, use plain prototypal object and expose full prototype (@rvagg)
- Move Batch object to batch.js and expose (@rvagg)
- Use new package, DeferredLevelDOWN to handle all deferred open logic (@rvagg)
- Code cleanup, update deps (xtend) (@rvagg, @juliangruber)
- Added
notFound
boolean property andstatus=404
property to NotFoundError (@rvagg) - Upgrade to errno@0.1.0 which aliases .type and .name properties (@rvagg)
- ReadStream gracefully handles multiple destroy() calls (@mcollina)
- New ReadStream: upgrade to streams2, remove all state-management cruft, remove fstream support (@substack)
- Update LevelDOWN dependency to ~0.8.0 with Iterator lt/lte/gt/gte support and NAN as a dependency
- Added @substack as contributor
- Encodings overhaul, allow custom encoders/decoders for
keyEncoding
orvalueEncoding
(@dominictarr)
- Update LevelDOWN dependency version ~0.7.0 for Node 0.8->0.11 compatibility
- Update LevelDOWN dependency version ~0.6.2
- Remove all Function#bind calls for better browser compatibility (@juliangruber)
- Switch from direct Buffer access to bops for better browser compatibility (@juliangruber)
- WriteStream#end accepts
data
argument (@pgte) - Added @pgte as contributor
- Upgrade to LevelDOWN@0.6.0 which upgrades to LevelDB@1.11.0, some important bugfixes: https://groups.google.com/forum/#!topic/leveldb/vS1JvmGlp4E
- Use LevelDOWN@0.5.0, see https://github.com/level/leveldown/blob/master/CHANGELOG.md for details
- Race-condition(ish) fixed in ReadStream--createReadStream() does not start immediately and therefore allowed put()s to happen before the stream starts (@dominictarr)
- ReadStream doesn't emit "ready" event (@dominictarr)
- Allow separate encodings per operation in db.batch() (@juliangruber)
- Allow separate encodings per write() in WriteStream (@juliangruber)
- WriteStream supports "type" option ("put" [default] or "del") on constructor and individual write()s (@mcollina)
- Remove "leveldown" from dependencies (see http://r.va.gg/2013/05/levelup-v0.9-some-major-changes.html) (@rvagg)
- Expose LevelDOWN (or LevelDOWN substitute) as
db
property on LevelUP instance (e.g. db.db.approximateSize()) - Chained batch exposed from LevelDOWN, invoked with argument-less db.batch() (@juliangruber, @rvagg)
- Significantly improve ReadStream performance by replacing .bind() and .apply() (@mcollina, @kesla)
- Better Browserify support (@rvagg, @juliangruber, @maxogden, etc.)
- Deprecate secondary LevelDB-specific operations on LevelUP, prefer direct LevelDOWN access (approximateSize(), repair(), destroy(), getProperty()--new in LevelDOWN@0.5.0) (@rvagg)
- More comprehensive argument checking, will now report back directly or throw if there is a problem rather than on nextTick (@rvagg)
- Expose
.options
property on LevelUP instances. (@rvagg) - Further clarify 'encoding' -> 'valueEncoding' shift. db.options.valueEncoding is now authoritative even if user used 'encoding' on initialisation. (@rvagg)
- 'level' package now published to npm that bundles LevelUP & LevelDOWN and exposes LevelUP directly; for planned shift to detaching LevelDOWN as a direct-dependency of LevelUP. (@rvagg)
- Windows support in LevelDOWN @0.2.0 (@rvagg)
- added 'db' option on constructor to replace LevelDOWN (@rvagg)
- added repair() & destroy() aliases for LevelDOWN implementations (@rvagg)
- fix early 'close' emit in WriteStream (@rvagg)
- improved ReadStream reverse=true start key handling (@kesla)
- ReadStream empty start & end keys ignored rather than segfault (@kesla)
- 'encoding' option now an alias for 'valueEncoding' only, 'keyEncoding' defaults to 'utf8' and must be changed explicitly (@rvagg)
- use
xtend
package instead of internal util._extend @ralphtheninja - internal cleanup of
callback
argument detection @ralphtheninja - move deferred-open-operations into an internal
this._db
wrapper rather than make them call public .get()/.put() etc. for a second time @dominictarr
- internal code cleanup & refactoring @ralphtheninja
- fix multiple iterator.end() calls in ReadStreams throwing errors (destroy() called while read/next is in progress) #82 #83 #84 @rvagg
- complete transition to LevelDOWN for the LevelDB binding. No native code left in LevelUP @rvagg
- LevelDOWN now keeps its own ChangeLog at: https://github.com/level/leveldown/blob/master/CHANGELOG.md
- LevelDB@1.9.0 and Snappy@1.1.0 are included in LevelDOWN@0.1.2
- simplify callback signature (remove extra, undocumented properties from some callbacks) @rvagg / @dominictarr
- explicit namespaces in C++ @rvagg
- memory leak, Persistent callback not Dispose()d for
readStream()
@rvagg - allow one next() at a time, improve end() handling @rvagg
- ensure iterator end & next don't conflict @rvagg
- remove CloseError @ralphtheninja
- fix put/batch bug in WriteStream#_process() @ralphtheninja
- remove
useBatch
incopy()
@rvagg - move encodingOpts levelup.js -> util.js @ralphtheninja
- non-shrinkwrapped release @rvagg
location
exposed as read-only property on db object @rvagg- swap bufferstream dependency for simple-bufferstream, remove unnecessary compile @rvagg
- comment out all sqlite3 benchmarks @ralphtheninja
- put LevelUP() into closure @ralphtheninja
- fix: incorrect scope in approximateSize function @sandfox
- change
createIfMissing
option default totrue
@rvagg - use util._extend instead of local variant @rvagg
- adjust copyright & contributors @rvagg
- idempotent open and close, and emit _state as events @dominictarr
- fix: check that UINT32_OPTION_VALUE is a Uint32 @kesla
- feature: Support setting size of LRU-cache @kesla
- use util.inherits() from node core @ralphtheninja
- set maxListeners to Infinity to prevent warnings when using deferred open @juliangruber
- added @kesla to contributors list @rvagg
- feature: added approximateSize() @kesla
- process.nextTick->setImmediate with polyfill Node 0.9.5 compat @rvagg
- added @ralphtheninja to contributors list @rvagg
- remove
useBatch
option onwriteStream()
@rvagg
- remove old, unused util functions @rvagg
- speed up batch() & allow non-Strings to C++ @rvagg
- fix batch() benchmarks @rvagg
- improved compression test @rvagg
- added SQLite3 to test suite @rvagg
- remove compile warnings on osx @rvagg
- return Strings not Buffers from C++ when possible @rvagg
- optimised encoders & decoders @rvagg
- added basic get() benchmarks @rvagg
- revamped benchmark suite @rvagg
- allow JS Strings through to native layer @rvagg
- cleaner build for osx @rvagg
- remove compile warnings for solaris @rvagg
- LevelDB 1.7 @rvagg
- added
compress
boolean on open() @rvagg
- stuff