Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
Remove legacy range options from readme and tests (Level/community#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
vweevers committed Apr 17, 2021
1 parent 762d989 commit 2df2a44
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 38 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,6 @@ You can supply an options object as the first parameter to `createReadStream()`

- `values` _(boolean, default: `true`)_: whether the results should contain values. If set to `true` and `keys` set to `false` then results will simply be values, rather than objects with a `value` property. Used internally by the `createValueStream()` method.

Legacy options:

- `start`: instead use `gte`

- `end`: instead use `lte`

<a name="createKeyStream"></a>

### `db.createKeyStream([options])`
Expand Down
64 changes: 32 additions & 32 deletions test/read-stream-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ module.exports = function (test, testCommon) {
})
}))

test('ReadStream: readStream() with "start"', makeTest(function (t, db, ctx, done) {
test('ReadStream: readStream() with "gte"', makeTest(function (t, db, ctx, done) {
db.batch(ctx.sourceData.slice(), function (err) {
t.ifError(err)

const rs = createReadStream(db, { start: '50' })
const rs = createReadStream(db, { gte: '50' })
rs.on('data', ctx.dataSpy)
rs.on('end', ctx.endSpy)
rs.on('close', function () {
Expand All @@ -181,11 +181,11 @@ module.exports = function (test, testCommon) {
})
}))

test('ReadStream: readStream() with "start" and "reverse=true"', makeTest(function (t, db, ctx, done) {
test('ReadStream: readStream() with "lte" and "reverse=true"', makeTest(function (t, db, ctx, done) {
db.batch(ctx.sourceData.slice(), function (err) {
t.ifError(err)

const rs = createReadStream(db, { start: '50', reverse: true })
const rs = createReadStream(db, { lte: '50', reverse: true })
rs.on('data', ctx.dataSpy)
rs.on('end', ctx.endSpy)
rs.on('close', function () {
Expand All @@ -196,12 +196,12 @@ module.exports = function (test, testCommon) {
})
}))

test('ReadStream: readStream() with "start" being mid-way key (float)', makeTest(function (t, db, ctx, done) {
test('ReadStream: readStream() with "gte" being mid-way key (float)', makeTest(function (t, db, ctx, done) {
db.batch(ctx.sourceData.slice(), function (err) {
t.ifError(err)

// '49.5' doesn't actually exist but we expect it to start at '50' because '49' < '49.5' < '50' (in string terms as well as numeric)
const rs = createReadStream(db, { start: '49.5' })
const rs = createReadStream(db, { gte: '49.5' })
rs.on('data', ctx.dataSpy)
rs.on('end', ctx.endSpy)
rs.on('close', function () {
Expand All @@ -212,11 +212,11 @@ module.exports = function (test, testCommon) {
})
}))

test('ReadStream: readStream() with "start" being mid-way key (float) and "reverse=true"', makeTest(function (t, db, ctx, done) {
test('ReadStream: readStream() with "lte" being mid-way key (float) and "reverse=true"', makeTest(function (t, db, ctx, done) {
db.batch(ctx.sourceData.slice(), function (err) {
t.ifError(err)

const rs = createReadStream(db, { start: '49.5', reverse: true })
const rs = createReadStream(db, { lte: '49.5', reverse: true })
rs.on('data', ctx.dataSpy)
rs.on('end', ctx.endSpy)
rs.on('close', function () {
Expand All @@ -227,13 +227,13 @@ module.exports = function (test, testCommon) {
})
}))

test('ReadStream: readStream() with "start" being mid-way key (string)', makeTest(function (t, db, ctx, done) {
test('ReadStream: readStream() with "gte" being mid-way key (string)', makeTest(function (t, db, ctx, done) {
db.batch(ctx.sourceData.slice(), function (err) {
t.ifError(err)

// '499999' doesn't actually exist but we expect it to start at '50' because '49' < '499999' < '50' (in string terms)
// the same as the previous test but we're relying solely on string ordering
const rs = createReadStream(db, { start: '499999' })
const rs = createReadStream(db, { gte: '499999' })
rs.on('data', ctx.dataSpy)
rs.on('end', ctx.endSpy)
rs.on('close', function () {
Expand All @@ -244,11 +244,11 @@ module.exports = function (test, testCommon) {
})
}))

test('ReadStream: readStream() with "end"', makeTest(function (t, db, ctx, done) {
test('ReadStream: readStream() with "lte"', makeTest(function (t, db, ctx, done) {
db.batch(ctx.sourceData.slice(), function (err) {
t.ifError(err)

const rs = createReadStream(db, { end: '50' })
const rs = createReadStream(db, { lte: '50' })
rs.on('data', ctx.dataSpy)
rs.on('end', ctx.endSpy)
rs.on('close', function () {
Expand All @@ -259,11 +259,11 @@ module.exports = function (test, testCommon) {
})
}))

test('ReadStream: readStream() with "end" being mid-way key (float)', makeTest(function (t, db, ctx, done) {
test('ReadStream: readStream() with "lte" being mid-way key (float)', makeTest(function (t, db, ctx, done) {
db.batch(ctx.sourceData.slice(), function (err) {
t.ifError(err)

const rs = createReadStream(db, { end: '50.5' })
const rs = createReadStream(db, { lte: '50.5' })
rs.on('data', ctx.dataSpy)
rs.on('end', ctx.endSpy)
rs.on('close', function () {
Expand All @@ -274,11 +274,11 @@ module.exports = function (test, testCommon) {
})
}))

test('ReadStream: readStream() with "end" being mid-way key (string)', makeTest(function (t, db, ctx, done) {
test('ReadStream: readStream() with "lte" being mid-way key (string)', makeTest(function (t, db, ctx, done) {
db.batch(ctx.sourceData.slice(), function (err) {
t.ifError(err)

const rs = createReadStream(db, { end: '50555555' })
const rs = createReadStream(db, { lte: '50555555' })
rs.on('data', ctx.dataSpy)
rs.on('end', ctx.endSpy)
rs.on('close', function () {
Expand All @@ -289,11 +289,11 @@ module.exports = function (test, testCommon) {
})
}))

test('ReadStream: readStream() with "end" being mid-way key (float) and "reverse=true"', makeTest(function (t, db, ctx, done) {
test('ReadStream: readStream() with "gte" being mid-way key (float) and "reverse=true"', makeTest(function (t, db, ctx, done) {
db.batch(ctx.sourceData.slice(), function (err) {
t.ifError(err)

const rs = createReadStream(db, { end: '50.5', reverse: true })
const rs = createReadStream(db, { gte: '50.5', reverse: true })
rs.on('data', ctx.dataSpy)
rs.on('end', ctx.endSpy)
rs.on('close', function () {
Expand All @@ -303,11 +303,11 @@ module.exports = function (test, testCommon) {
})
}))

test('ReadStream: readStream() with both "start" and "end"', makeTest(function (t, db, ctx, done) {
test('ReadStream: readStream() with both "gte" and "lte"', makeTest(function (t, db, ctx, done) {
db.batch(ctx.sourceData.slice(), function (err) {
t.ifError(err)

const rs = createReadStream(db, { start: 30, end: 70 })
const rs = createReadStream(db, { gte: 30, lte: 70 })
rs.on('data', ctx.dataSpy)
rs.on('end', ctx.endSpy)
rs.on('close', function () {
Expand All @@ -318,11 +318,11 @@ module.exports = function (test, testCommon) {
})
}))

test('ReadStream: readStream() with both "start" and "end" and "reverse=true"', makeTest(function (t, db, ctx, done) {
test('ReadStream: readStream() with both "gte" and "lte" and "reverse=true"', makeTest(function (t, db, ctx, done) {
db.batch(ctx.sourceData.slice(), function (err) {
t.ifError(err)

const rs = createReadStream(db, { start: 70, end: 30, reverse: true })
const rs = createReadStream(db, { gte: 30, lte: 70, reverse: true })
rs.on('data', ctx.dataSpy)
rs.on('end', ctx.endSpy)
rs.on('close', function () {
Expand Down Expand Up @@ -371,11 +371,11 @@ module.exports = function (test, testCommon) {
})
}))

test('ReadStream: ReadStream, start=0', makeTest(function (t, db, ctx, done) {
test('ReadStream: ReadStream, gte=0', makeTest(function (t, db, ctx, done) {
db.batch(ctx.sourceData.slice(), function (err) {
t.ifError(err)

const rs = createReadStream(db, { start: 0 })
const rs = createReadStream(db, { gte: 0 })
rs.on('data', ctx.dataSpy)
rs.on('end', ctx.endSpy)
rs.on('close', function () {
Expand All @@ -387,11 +387,11 @@ module.exports = function (test, testCommon) {

// we don't expect any data to come out of here because the keys start at '00' not 0
// we just want to ensure that we don't kill the process
test('ReadStream: ReadStream, end=0', makeTest(function (t, db, ctx, done) {
test('ReadStream: ReadStream, lte=0', makeTest(function (t, db, ctx, done) {
db.batch(ctx.sourceData.slice(), function (err) {
t.ifError(err)

const rs = createReadStream(db, { end: 0 })
const rs = createReadStream(db, { lte: 0 })
rs.on('data', ctx.dataSpy)
rs.on('end', ctx.endSpy)
rs.on('close', function () {
Expand Down Expand Up @@ -451,11 +451,11 @@ module.exports = function (test, testCommon) {
})
}))

test('ReadStream: readStream() with "start" and "limit"', makeTest(function (t, db, ctx, done) {
test('ReadStream: readStream() with "gte" and "limit"', makeTest(function (t, db, ctx, done) {
db.batch(ctx.sourceData.slice(), function (err) {
t.ifError(err)

const rs = createReadStream(db, { start: '20', limit: 20 })
const rs = createReadStream(db, { gte: '20', limit: 20 })
rs.on('data', ctx.dataSpy)
rs.on('end', ctx.endSpy)
rs.on('close', function () {
Expand All @@ -465,11 +465,11 @@ module.exports = function (test, testCommon) {
})
}))

test('ReadStream: readStream() with "end" after "limit"', makeTest(function (t, db, ctx, done) {
test('ReadStream: readStream() with "lte" after "limit"', makeTest(function (t, db, ctx, done) {
db.batch(ctx.sourceData.slice(), function (err) {
t.ifError(err)

const rs = createReadStream(db, { end: '50', limit: 20 })
const rs = createReadStream(db, { lte: '50', limit: 20 })
rs.on('data', ctx.dataSpy)
rs.on('end', ctx.endSpy)
rs.on('close', function () {
Expand All @@ -479,11 +479,11 @@ module.exports = function (test, testCommon) {
})
}))

test('ReadStream: readStream() with "end" before "limit"', makeTest(function (t, db, ctx, done) {
test('ReadStream: readStream() with "lte" before "limit"', makeTest(function (t, db, ctx, done) {
db.batch(ctx.sourceData.slice(), function (err) {
t.ifError(err)

const rs = createReadStream(db, { end: '30', limit: 50 })
const rs = createReadStream(db, { lte: '30', limit: 50 })
rs.on('data', ctx.dataSpy)
rs.on('end', ctx.endSpy)
rs.on('close', function () {
Expand Down

0 comments on commit 2df2a44

Please sign in to comment.