-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.ts
52 lines (45 loc) · 1.15 KB
/
setup.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
47
48
49
50
51
52
import {
Field,
PrimaryKey,
SearchField,
Tigris,
TigrisCollection,
TigrisDataTypes
} from "@tigrisdata/core";
@TigrisCollection("comments")
class Comment {
@PrimaryKey(TigrisDataTypes.UUID, { order: 1, autoGenerate: true })
id?: string;
@Field()
message!: string;
@Field()
@SearchField({ facet: true, sort: true })
slug!: string;
@Field(TigrisDataTypes.DATE_TIME)
@SearchField({ sort: true })
createdAt?: Date;
@Field()
name!: string;
}
async function main() {
// setup client
const tigrisClient = new Tigris({
branch: "main",
projectName: "YOUR_TIGRIS_PROJECT_NAME",
clientId: "YOUR_TIGRIS_CLIENT_ID",
clientSecret: "YOUR_TIGRIS_CLIENT_SECRET",
});
// ensure branch exists, create it if it needs to be created dynamically
await tigrisClient.getDatabase().initializeBranch();
// register schemas
await tigrisClient.registerSchemas([Comment]);
}
main()
.then(async () => {
console.log("Setup complete ...");
process.exit(0);
})
.catch(async (e) => {
console.error(e);
process.exit(1);
});