diff --git a/README.md b/README.md index fc4fb95..ea2a222 100644 --- a/README.md +++ b/README.md @@ -24,12 +24,14 @@ const db = new RaveLevel('./db') ### `db = new RaveLevel(location[, options])` -The `location` argument is the same as in [`classic-level`](https://github.com/Level/classic-level), making `rave-level` a drop-in replacement for when you need to read and write to the given `location` from multiple processes simultaneously. However, the `options` are different and limited because not every `RaveLevel` instance has direct access to the underlying LevelDB database. The `options` object may contain: +The `location` argument is the same as in [`classic-level`](https://github.com/Level/classic-level), making `rave-level` a drop-in replacement for when you need to read and write to the given `location` from multiple processes simultaneously. The `options` object may contain: - `keyEncoding` (string or object, default `'utf8'`): [encoding](https://github.com/Level/abstract-level#encodings) to use for keys - `valueEncoding` (string or object, default `'utf8'`): encoding to use for values - `retry` (boolean, default `true`): if true, operations are retried upon connecting to a new leader. This disables [snapshot guarantees](https://github.com/Level/abstract-level#iterator) because retries may implicitly use new snapshots. If false, operations are aborted upon disconnect, which means to yield an error on e.g. `db.get()`. +Additionnaly, all the options accepted by [`classic-level`](https://github.com/Level/classic-level#db--new-classiclevellocation-options) are also accepted by `rave-level` but will only have an effect for the leader instance. + The `RaveLevel` class extends `AbstractLevel` and thus follows the public API of [`abstract-level`](https://github.com/Level/abstract-level). As such, the rest of the API is documented in `abstract-level`. The database opens itself but (unlike other `abstract-level` implementations) cannot be re-opened once `db.close()` has been called. Calling `db.open()` would then yield a [`LEVEL_NOT_SUPPORTED`](https://github.com/Level/abstract-level#errors) error. ### Events diff --git a/index.d.ts b/index.d.ts index 18a6f01..814b115 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,5 @@ -import { AbstractLevel, AbstractDatabaseOptions } from 'abstract-level' +import { AbstractLevel } from 'abstract-level' +import { DatabaseOptions as ClassicLevelDatabaseOptions } from 'classic-level' /** * Use a [LevelDB](https://github.com/google/leveldb) database from multiple processes @@ -26,7 +27,7 @@ export class RaveLevel * Options for the {@link RaveLevel} constructor. */ declare interface DatabaseOptions extends - Omit, 'createIfMissing' | 'errorIfExists'> { + ClassicLevelDatabaseOptions { /** * If true, operations are retried upon connecting to a new leader. If false, * operations are aborted upon disconnect, which means to yield an error on e.g. diff --git a/index.js b/index.js index ca741c6..2b95d03 100644 --- a/index.js +++ b/index.js @@ -26,7 +26,7 @@ exports.RaveLevel = class RaveLevel extends ManyLevelGuest { this[kLocation] = path.resolve(location) this[kSocketPath] = socketPath(this[kLocation]) - this[kOptions] = { keyEncoding, valueEncoding } + this[kOptions] = options this[kConnect] = this[kConnect].bind(this) this[kDestroy] = this[kDestroy].bind(this) diff --git a/package.json b/package.json index 9585ec6..9fb4635 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rave-level", - "version": "1.0.0", + "version": "1.0.1", "description": "Use a LevelDB database from multiple processes with seamless failover", "license": "MIT", "main": "index.js",