Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ulixee
GitHub Repository: ulixee/secret-agent
Path: blob/main/core/models/OutputTable.ts
1028 views
1
import { Database as SqliteDatabase } from 'better-sqlite3';
2
import SqliteTable from '@secret-agent/commons/SqliteTable';
3
4
export default class OutputTable extends SqliteTable<IOutputChangeRecord> {
5
constructor(readonly db: SqliteDatabase) {
6
super(
7
db,
8
'Output',
9
[
10
['type', 'TEXT'],
11
['path', 'TEXT'],
12
['value', 'TEXT'],
13
['lastCommandId', 'INTEGER'],
14
['timestamp', 'INTEGER'],
15
],
16
true,
17
);
18
}
19
20
public insert(record: IOutputChangeRecord) {
21
const { type, path, value, lastCommandId, timestamp } = record;
22
return this.queuePendingInsert([
23
type,
24
path,
25
JSON.stringify(value),
26
lastCommandId,
27
timestamp.getTime(),
28
]);
29
}
30
}
31
32
export interface IOutputChangeRecord {
33
type: string;
34
path: string;
35
value: string;
36
lastCommandId: number;
37
timestamp: Date;
38
}
39
40