-
Notifications
You must be signed in to change notification settings - Fork 36
/
scan.ts
46 lines (43 loc) · 1.65 KB
/
scan.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import type {ReadonlyJSONValue} from '../json';
// TODO(arv): Unify with src/scan-options.ts
// How to use ScanOptions. This could be simpler if we added more structure, eg
// separate scan types for regular vs index scans, but opting instead for
// simpler structure at the cost of making it slightly harder to hold.
//
// For *all* scans:
// - limit: only return at most this many matches
//
// For *regular* scans:
// - prefix: (primary) key prefix to scan, "" matches all of them
// - start_key: start returning (primary key) matches from this value, inclusive
// unless:
// - start_exclusive: start returning matches *after* the start_key
// - start_key can be used for pagination
//
// For *index* scans:
// - index_name: name of the index to use
// - prefix: *secondary* key prefix to scan for, "" matches all of them
// - start_secondary_key: start returning *secondary* key matches from this
// value, AND:
// - start_key: if provided start matching on EXACTLY the start_secondary_key
// and return *primary* key matches starting from this value (empty string
// means all of them).
// - start_exclusive: start returning matches *after* the (start_secondary_key,
// start_key) entry; exclusive covers both
// - start_secondary_key and start_key can be used for pagination
//
// NOTE that in above for index scans if you provide Some start_key, the
// secondary_index_key is treated as an exact match.
export type ScanOptions = {
prefix?: string;
startSecondaryKey?: string;
startKey?: string;
startExclusive?: boolean;
limit?: number;
indexName?: string;
};
export type ScanItem = {
primaryKey: string;
secondaryKey: string;
val: ReadonlyJSONValue;
};