Skip to content

Commit b2db7e5

Browse files
authored
Merge pull request #186 from HarperFast/fix-getkeys
2 parents 3a7a5ee + 855e268 commit b2db7e5

File tree

3 files changed

+7
-31
lines changed

3 files changed

+7
-31
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ Synchronous version of `get()`.
165165
Retrieves all keys within a range.
166166

167167
```typescript
168-
for (const { key, value } of db.getKeys()) {
169-
console.log({ key, value });
168+
for (const key of db.getKeys()) {
169+
console.log(key);
170170
}
171171
```
172172

src/dbi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ export class DBI<T extends DBITransactional | unknown = unknown> {
349349
return this.store.getRange(this.#context, {
350350
...options,
351351
values: false
352-
});
352+
}).map(item => item.key);
353353
}
354354

355355
/**

test/ranges.test.ts

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,7 @@ describe('Ranges', () => {
240240
}
241241

242242
const iter = db.getKeys();
243-
expect(Array.from(iter)).toEqual([
244-
{ key: 'a' },
245-
{ key: 'b' },
246-
{ key: 'c' },
247-
{ key: 'd' },
248-
{ key: 'e' }
249-
]);
243+
expect(Array.from(iter)).toEqual(['a', 'b', 'c', 'd', 'e']);
250244
}));
251245

252246
it('should get keys only in a column family', () => dbRunner({
@@ -257,13 +251,7 @@ describe('Ranges', () => {
257251
}
258252

259253
const iter = db.getKeys();
260-
expect(Array.from(iter)).toEqual([
261-
{ key: 'a' },
262-
{ key: 'b' },
263-
{ key: 'c' },
264-
{ key: 'd' },
265-
{ key: 'e' }
266-
]);
254+
expect(Array.from(iter)).toEqual(['a', 'b', 'c', 'd', 'e']);
267255
}));
268256

269257
it('should get keys only for a transaction', () => dbRunner(async ({ db }) => {
@@ -273,13 +261,7 @@ describe('Ranges', () => {
273261

274262
await db.transaction(async txn => {
275263
const iter = txn.getKeys();
276-
expect(Array.from(iter)).toEqual([
277-
{ key: 'a' },
278-
{ key: 'b' },
279-
{ key: 'c' },
280-
{ key: 'd' },
281-
{ key: 'e' }
282-
]);
264+
expect(Array.from(iter)).toEqual(['a', 'b', 'c', 'd', 'e']);
283265
});
284266
}));
285267

@@ -292,13 +274,7 @@ describe('Ranges', () => {
292274

293275
await db.transaction(async txn => {
294276
const iter = txn.getKeys();
295-
expect(Array.from(iter)).toEqual([
296-
{ key: 'a' },
297-
{ key: 'b' },
298-
{ key: 'c' },
299-
{ key: 'd' },
300-
{ key: 'e' }
301-
]);
277+
expect(Array.from(iter)).toEqual(['a', 'b', 'c', 'd', 'e']);
302278
});
303279
}));
304280

0 commit comments

Comments
 (0)