diff --git a/README.md b/README.md index a3cefe7..bc739bc 100644 --- a/README.md +++ b/README.md @@ -41,42 +41,42 @@ Given zero or more manifest objects, returns a merged and enriched manifest obje For future extensibility, the properties are truthy rather than strictly typed booleans. Falsy or absent properties are converted to `false`, other values are allowed: ```js -supports().snapshots // false -supports({ snapshots: true }).snapshots // true -supports({ snapshots: {} }).snapshots // {} -supports({ snapshots: 1 }, { snapshots: 2 }).snapshots // 2 +supports().seek // false +supports({ seek: true }).seek // true +supports({ seek: {} }).seek // {} +supports({ seek: 1 }, { seek: 2 }).seek // 2 ``` For consumers of the manifest this means they should check support like so: ```js -if (db.supports.snapshots) +if (db.supports.seek) ``` Rather than: ```js -if (db.supports.snapshots === true) +if (db.supports.seek === true) ``` **Note:** the manifest describes high-level features that typically encompass multiple methods of a db. It is currently not a goal to describe a full API, or versions of it. ## Features -### `snapshots` (boolean) +### `implicitSnapshots` (boolean) -Does the database have snapshot guarantees? Meaning that reads are unaffected by simultaneous writes. For example, an iterator should read from a snapshot of the database, created at the time `db.iterator()` was called. This means the iterator will not see the data of simultaneous write operations. - -Must be `false` if any of the following is true: +Does the database read from a snapshot as described in [`abstract-level`](https://github.com/Level/abstract-level#reading-from-snapshots)? Must be `false` if any of the following is true: - Reads don't operate on a snapshot - Snapshots are created asynchronously. +Aliased as `snapshots` for backwards compatibility. +
Support matrix -| Module | Snapshot guarantee | -| :------------------- | :-------------------------- | +| Module | Implicit snapshots | +| :------------------- | :---------------------------- | | `classic-level` | ✅ | | `memory-level` | ✅ | | `browser-level` | ❌ | @@ -98,6 +98,22 @@ Must be `false` if any of the following is true:
+### `explicitSnapshots` (boolean) + +Does the database implement `db.snapshot()` and do read methods accept a `snapshot` option as described in [`abstract-level`](https://github.com/Level/abstract-level#reading-from-snapshots)? + +
+Support matrix + +| Module | Explicit snapshots | +| :------------------- | :-------------------------- | +| `classic-level` | Not yet | +| `memory-level` | Not yet | +| `browser-level` | ❌ | +| `rave-level` | TBD | + +
+ ### `permanence` (boolean) Does data survive after process (or environment) exit? Typically true. False for [`memory-level`](https://github.com/Level/memory-level) and [`memdown`](https://github.com/Level/memdown). diff --git a/index.js b/index.js index 803956c..618aa6c 100644 --- a/index.js +++ b/index.js @@ -3,8 +3,14 @@ exports.supports = function supports (...manifests) { const manifest = manifests.reduce((acc, m) => Object.assign(acc, m), {}) + // Snapshots is an alias for backwards compatibility + const implicitSnapshots = manifest.implicitSnapshots || manifest.snapshots || false + const explicitSnapshots = manifest.explicitSnapshots || false + return Object.assign(manifest, { - snapshots: manifest.snapshots || false, + implicitSnapshots, + explicitSnapshots, + snapshots: implicitSnapshots, permanence: manifest.permanence || false, seek: manifest.seek || false, createIfMissing: manifest.createIfMissing || false, diff --git a/test/self.js b/test/self.js index 2382a30..78eb8aa 100644 --- a/test/self.js +++ b/test/self.js @@ -73,3 +73,14 @@ test('does not merge additionalMethods', function (t) { t.same(manifest.additionalMethods, { bar: true }) t.end() }) + +test('adds snapshots alias', function (t) { + for (const value of [true, false]) { + t.is(supports({ implicitSnapshots: value }).implicitSnapshots, value) + t.is(supports({ implicitSnapshots: value }).snapshots, value) + t.is(supports({ snapshots: value }).implicitSnapshots, value) + t.is(supports({ snapshots: value }).snapshots, value) + } + + t.end() +})