forked from rocicorp/replicache
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
55 lines (46 loc) · 1.48 KB
/
Copy pathindex.ts
File metadata and controls
55 lines (46 loc) · 1.48 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
50
51
52
53
54
55
import {REPMHTTPInvoker} from './repm-invoker.js';
import Replicache from './replicache.js';
(async () => {
const invoker = new REPMHTTPInvoker('http://localhost:7002');
await invoker.invoke('test', 'open');
const {transactionId} = await invoker.invoke('test', 'openTransaction', {});
const putResponse = await invoker.invoke('test', 'put', {
transactionId,
key: '/v',
value: 1,
});
console.log(putResponse);
await invoker.invoke('test', 'commitTransaction', {transactionId});
{
const {transactionId} = await invoker.invoke('test', 'openTransaction', {});
const getResponse = await invoker.invoke('test', 'get', {
transactionId,
key: '/v',
});
console.log(getResponse);
await invoker.invoke('test', 'closeTransaction', {transactionId});
}
{
const {transactionId} = await invoker.invoke('test', 'openTransaction', {});
const scanResponse = await invoker.invoke('test', 'scan', {
transactionId,
});
console.log(scanResponse);
await invoker.invoke('test', 'closeTransaction', {transactionId});
}
await invoker.invoke('test', 'close');
const repmInvoke = invoker.invoke;
document.body.textContent = JSON.stringify(
await Replicache.list({repmInvoke}),
null,
2,
);
document.body.textContent += ';\n';
await Replicache.drop('test', {repmInvoke});
document.body.textContent += ';\n';
document.body.textContent += JSON.stringify(
await Replicache.list({repmInvoke}),
null,
2,
);
})();