-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathSyncDataBucket.ts
More file actions
49 lines (45 loc) · 1.16 KB
/
SyncDataBucket.ts
File metadata and controls
49 lines (45 loc) · 1.16 KB
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
47
48
49
import { OpId } from './CrudEntry.js';
import { OplogEntry, OplogEntryJSON } from './OplogEntry.js';
export type SyncDataBucketJSON = {
bucket: string;
has_more?: boolean;
after?: string;
next_after?: string;
data: OplogEntryJSON[];
};
export class SyncDataBucket {
static fromRow(row: SyncDataBucketJSON) {
return new SyncDataBucket(
row.bucket,
row.data.map((entry) => OplogEntry.fromRow(entry)),
row.has_more ?? false,
row.after,
row.next_after
);
}
constructor(
public bucket: string,
public data: OplogEntry[],
/**
* True if the response does not contain all the data for this bucket, and another request must be made.
*/
public has_more: boolean,
/**
* The `after` specified in the request.
*/
public after?: OpId,
/**
* Use this for the next request.
*/
public next_after?: OpId
) {}
toJSON(fixedKeyEncoding = false): SyncDataBucketJSON {
return {
bucket: this.bucket,
has_more: this.has_more,
after: this.after,
next_after: this.next_after,
data: this.data.map((entry) => entry.toJSON(fixedKeyEncoding))
};
}
}